stringtokenizer problems :(

can someone tell me why my code isnt working, i want my while statement to run while a full name hasnt been entered using the tokens method, however i am having trouble its only registering the one even when i put more then one name in the input :( someone please help its urgent.

Scanner console = new Scanner(System.in);//New Scanned named console

String Name = "";//Where full name will be stored.

int tokenCounter = 0;//Token Counter variable

String inputLine;//inputLine has the data type String

my while statement:

while ( tokenCounter < 2 )

{

System.out.print("Please enter your full name:");

Name = console.next();

StringTokenizer st = new StringTokenizer(Name);

tokenCounter = st.countTokens();

System.out.println("Number of tokens = " +tokenCounter);

}

my test code worked standalone but not when i used an input :(

this was the test code:

String text = "work **** it";

StringTokenizer st = new StringTokenizer(text);

System.out.println (st.countTokens());

[1098 byte] By [balistica] at [2007-11-27 0:13:53]
# 1
Because you are re-creating the tokenizer within the loop.- Saish
Saisha at 2007-7-11 21:58:16 > top of Java-index,Java Essentials,New To Java...
# 2
Sorry, did not see what you were trying to do. Try using Scanner#nextLine instead of Scanner#next.
Saisha at 2007-7-11 21:58:16 > top of Java-index,Java Essentials,New To Java...
# 3
thank you, thank you, it works :D im so happy
balistica at 2007-7-11 21:58:16 > top of Java-index,Java Essentials,New To Java...
# 4
Glad I could help. Best of luck.- Saish
Saisha at 2007-7-11 21:58:16 > top of Java-index,Java Essentials,New To Java...