class MyClass2 { private int counter; int Counter () { return counter; } void Counter ( int val ) {counter = val; } } class Test2 { public static void main (String args[]) { MyClass2 myinstance = new MyClass2(); int myval; myinstance.Counter(20); myval = myinstance.Counter(); System.out.println("Counter = " + myval); } }