How to share a variable across classes in Java, I tried static didn't work
<p>class Testclass1   has a variable, there is some execution which will change value of variable. Now in same package there is class Testclass2 . How will I access updated value(updated by Testclass1) of variable in Testclass2.
tried this didn't work </p>

<p>Note: Testclass1 and Testclass2 are two separate files in same package, I tried to run class1 first in eclipse and then class2. But class2 printed 0;</p>

<pre><code>public class Testclass1 {
    public static int value;
    public static void main(String[]args)
    {
        Testclass1.value=9;
        System.out.println(value);
    }
}

----------------

public class Testclass2 {
    public static void main(String[]args)
    {
        System.out.println(Testclass1.value);
    }
}
</code></pre>
