public void function1(ActionEvent e) {
aVar=value In Input Box When button but1 is clicked;
}
}
now if i was trying to access the aVar in another class how would i do it...because right now im doing this and its giving me 0 instead of the new updated value.
public class bClass...{
aClass instance=new aClass();
System.out.println(instance.aVar).......prints 0 instead of the updated value;
}
It looks like you're doing it correctly. If it was wrong, the compiler would yell at you for trying to access something that was private access only.
When you are calling function1 to change the variable, are you sure it's in the same instance as the one you created in the other class? Because in your example
aClass instance=new aClass();
System.out.println(instance.aVar).......prints 0 instead of the updated value;
}
all you're doing is creating a new instance, then printing a variable from it. Since the method to change the variable was never used for that instance, it prints 0, which you have set as the default for the variable.
If that's not the problem you could send me your full code and I could see what I can do with it.
Users browsing this forum: No registered users and 0 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum