الرجوع
تسجيل الدخول

What is the output of this code?

public class Counter {
    private int count = 0;

    public void increment() {
        count++;
    }

    public int getCount() {
        return count;
    }
}

public class Main {
    public static void main(String[] args) {
        Counter myCounter = new Counter();
        myCounter.increment();
        myCounter.increment();
        System.out.println(myCounter.getCount());
    }
}