阅前声明: http://blog.csdn.net/heimaoxiaozi/archive/2007/01/19/1487884.aspx
/****************** Exercise 8 ******************* Modify Exercise 7 so that your code is* surrounded by an "infinite" while loop. It* will then run until you interrupt it from the* keyboard (typically by pressing Control-C).***********************************************/import java.util.*;public class E08_RandomInts2 { static Random r = new Random(); public static void compareRand() { int a = r.nextInt(); int b = r.nextInt(); System.out.println("a = " + a + ", b = " + b); if(a < b) System.out.println("a < b"); else if (a > b) System.out.println("a > b"); else System.out.println("a = b"); } public static void main(String[] args) { while(true) compareRand(); }}
//+M echo skipping execution of RandomInts2...
**This requires only a minor change, in main( ).