The task is typing in some people's names and the output should be random pairs of these people. e.g. [awana]abc: java Pairs james alex jane james and jane alex My program is shown below: When running this program, the method randomPairs(nameSet) cannot be reached since the program cannot break out from the while-loop. I wonder how the method randomPairs(nameSet) can be executed after the while-loop. Thanks, Shen
Richard Jensen
Ranch Hand
Joined: May 14, 2003
Posts: 67
posted
0
Originally posted by Shen Lin: When running this program, the method randomPairs(nameSet) cannot be reached since the program cannot break out from the while-loop. I wonder how the method randomPairs(nameSet) can be executed after the while-loop. Thanks, Shen
When the input stream closes then the buffered reader will return null for the readLine. So, if you run from the command line you need to enter your names (one per line) and then enter the appropriate end of stream character for your OS (on Windows it is Ctrl-Z). It would also work by redirecting the contents of a file containing one name per line.
Richard
N 37 33 W 122 18
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.