Тест · Классы и объекты · урок 8 из 10
Тест — счётчик объектов
Что выведет программа?
public class Main {
public static void main(String[] args) {
Counter a = new Counter();
new Counter();
System.out.println(Counter.count + " " + a.id);
}
}
class Counter {
static int count;
int id;
Counter() { id = ++count; }
}