Monday, 19 August 2013

java - access incremented static variable from another class

java - access incremented static variable from another class

I have a static variable and updating it's value in class. But when i
access this variable from another class , it shows unupdated value.
class A
{
static int id=0;
//I am updating id in my function ,
function work()
{
id++;
}
}
class B
{
Log(A.id); //it always gives me 0 , even if id updated in class A
}
I need a global variable that i can access from each class and update its
value. Waiting for your help (I am using this with a Android Service)

No comments:

Post a Comment