A couple comments...
- You didn't fare very well over at the Sun forums (lesson learned: don't cross post)
- what you want to do is not as easy as it seems...
I'll try to explain....
you have two classes: Class A and Class B.
I think what you want to do is pass a variable value from class A so it can be used in class B... correct? Please make sure that this is what you want to do: can this be done in Class A with a mehtod?
You can't first run classA and then run class B for this to work. What has to happen is that you have to call the method that's in class B (from Class A) that needs that variable from Class A (sounds like "Who's on first?").
in Class A:
|
Code:
|
String varToSend ="Hello !!!";
ClassB cb = new ClassB(); //instantiate class B in class A
cb.heresTheVariable(varToSend);//call the class B method |
in Class B:
|
Code:
|
public void heresTheVariable(String varFromClassA)
{
System.out.println("The variable form class A: " + varFromClassA);
} |
Now in this example, I'm not returning anything from the class B method, so the example is not useful... it just shows how things flow (if i didn't goof anything up).
Luck,
CJSL