File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

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?

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

Joined: Jul 08, 2003
Posts: 24199

Dupe. See Here.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: help please...
It's not a secret anymore!