• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Displaying individual text

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello to everyone,
I am almost finished with a program except for creating a loop which will display all the words entered by a user and captured by the Keyboard.readString. I have enough code to display the first word but have been unsuccessful with a code that will display the words individually.
For example: I must go to the store.
token : |I|
token : |must|
token : |go|
etc.
Here is my code so far:

st = new StringTokenizer (entry);
while (st.hasMoreTokens())
{
String token = st.nexttoken();
System.out.println ("token : |" + token + "|");
Thank you very, very much for your help.
David
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Norman!
Other than your code example not being complete, and that you've misspelled the nextToken() method, your logic and syntax looks about correct. Was the misspelled method name perhaps the problem?
On a side note, something that I very much appreciated being pointed at when just starting to learn to program in Java (last week) is the Java 2 SE API documentation. It details all of the constructors and methods available in each class definition.
Note that the J2SE API documentation doesn't include the Keyboard class you mentioned as it's not part of the official Java libraries (API). I'd guess that you received Keyboard from a book, tutorial, or instructor. I would expect that the originator of the Keyboard class also has JavaDocs available of the same format and style of the J2SE API documentation linked above.
[ March 13, 2004: Message edited by: Dirk Schreckmann ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic