Heroes Come!

Category: Java EE
 
Ak922
2011-10-14 11:10:10

Sponsored Links
Heroes, run the following examples.

key is how to exit the loop? ?

/ **
@ version 1.00 1999-07-07
@ author Cay Horstmann
* /

import java.util. *;
import java.io. *;

/ **
; This program uses a set to print all unique words in
System.in.
* /
public class SetTest
{
public static void main (String [] args)
{
Set words = new HashSet (59999);
/ / set to HashSet, LinkedHashSet or TreeSet
long totalTime = 0;

try
{
BufferedReader in = new
BufferedReader (new InputStreamReader (System.in));
String line;
while ((line ; = in.readLine ())! = null)
{

; StringTokenizer tokenizer = new StringTokenizer (line);
; System.out.println (tokenizer.toString ());
while (tokenizer.hasMoreTokens ())
{
String word = tokenizer.nextToken ();
; long callTime = System.currentTimeMillis ();
words.add (word);
; callTime = System.currentTimeMillis () - callTime;
totalTime + = callTime;
}
}
}
; catch (IOException e)
{
; System.out.println ("Error" + e);
}

Iterator iter = words.iterator ();
while (iter.hasNext ())
System.out.println (iter.next ());
System . out.println (words.size ()
+ "distinct words." + totalTime + "milliseconds.");
}
}

Sponsored Links

bony123
2011-10-14 11:12:29
:)
while ((line = in.readLine ())! = null) do?
do not understand where some strange java function.
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.