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