Define a Counter class to represent
simple counting devices. It should include the following
methods.
Write your answer below.public static void run() { Counter a = new Counter(); Counter b = new Counter(); a.increment(); IO.println(a.getValue()); // prints ``1'' a.increment(); b.increment(); IO.println(a.getValue()); // prints ``2'' IO.println(b.getValue()); // prints ``1'' }
public class Counter { // : (your code here) }
public class Counter { private int val; public Counter() { val = 0; } public void increment() { val++; } public int getValue() { return val; } }