Is there any way to create a variable which i can change in class A and by these changes affect what will happen in another class B. Hope you understand.
Something like this:
class A{
public int var = 0;
}
And use value of variable var like this:
class B{
if(var == 0)
{
System.out.println("right now, var is equal 0");
}
else if(var == 1)
{
System.out.println("right now, var is equal 1");
}
}
Also as you can see, var can't be static because i need to change it's value during run of app.
Bhas a reference to a (shared?) instance ofA. But why wouldn't you use static for a global variable? And of course the requisite "why are you using global variables?"staticvariable during runtime.