This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Saving strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Saving strings" Watch "Saving strings" New topic

Saving strings

Josef Bartnick

Joined: Oct 23, 2003
Posts: 1
Is it possible to take input from the keyboard and save it as a string for future use in the code? If not, is there anything close to performing to what I want?
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Yes (of course). Look here

Please ignore post, I have no idea what I am talking about.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sure, you just need to think a bit about the scope of the data, which means when and where you want to use it. For example, here's method scope. I declare a string, get a value and use it all in one method. When I leave the method, it goes "out of scope" and is no longer available.

If I want to use it in another method, I have to make a longer scope. If I store it in a member variable, it lasts as long as the object:

Find a book like Bruce Eckell's Thinking In Java and look up scope in the index. They're likely to have a good discussion.
[ November 05, 2003: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
subject: Saving strings
Similar Threads
WA #1.....word association
Save pdf from http inputstream to file
How to print a String with out duplicates
conversational state of SFSB