, , , , , , ...
1: "counter1, counter2, counter3", ( ).
public class Counter {
static Counter counter1 = new Counter();
...
public void resetCounters() {
counter1.clear();
counter2.clear();
...
}
}
2: , , , , :
public class Counter {
public static void main(String[] args) {
Counter[] counters = {new Counter(), new Counter(), new Counter(), new Counter(), new Counter()};
...
}
static void resetCounters(Counter[] counters) {
for (Counter c : counters) {
c.reset();
}
}
}
, , factory. , , , .