This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Saving strings" Watch "Saving strings" New topic
Author

Saving strings

Josef Bartnick
Greenhorn

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: 986

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving strings