Communication between 2 Classes
<p>I'm a newbie java programer and I'm trying to make my first project.</p>

<p>I need to pass a variable between 2 classes, which is going fine. The problem is that the variable has a changing value and i cannot pass the actual value. Here is an example:</p>

<pre><code>public class A{
    private int counter = 0;

    public int getCounter(){
        return counter;
    }

    //here some code which will increase or decrease the value of the counter variable 
    //lets say for the sake of the example that at this point the value of the variable is 1.
    //counter = 1;
}

public class B{
    public static void main(String[] args) {
        A a = new A();
        System.out.println(a.getCounter());// here I need the actual counter variable value which is currently: 1
    }
}
</code></pre>

<p>My problem is that i always receive 0. How can i pass the actual value of the variable.</p>

<p>Any help or advice is greatly appreciated.</p>
