This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes help please... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

help please...

Lawrence Buensalida
Ranch Hand

Joined: May 18, 2005
Posts: 38
This may sound easy to you that's why I need your help. How do I use a string value from one class to another class?

Example: I have a string in class A and I want to use it for a decision in class B. How do I do that? Will you help me?

Thanks.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
One way would be to make a public method to retrieve the string from class A. For example, say this simple class which represents a person was your 'A' class:


Then in your 'B' class you would call the getName() method to find out the value of the name variable. Something like this:

[ June 10, 2005: Message edited by: Stuart Gray ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Dupe. See Here.


[Jess in Action][AskingGoodQuestions]
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: help please...