in的计数器在变化,但是在LInkedList中,每个t都具有i的最大值。我在做什么错了?
public class Test {
public static void main(String[] args) {
getUnit("LPE", new LowPowerEngine()).getCounter();
}
public static <T extends IUnitSpecification> T getUnit(String key, T t) {
return t = controlUnitAvailability(key, t);
}
private static <T extends IUnitSpecification> T controlUnitAvailability(String key, T t) {
LinkedList<T> unitStock = new LinkedList<>();
int minimumAmount = 3;
int partySize = 15;
int counter = 0;
if (unitStock.size() < minimumAmount) {
for (int i = 0; i < partySize; i++) {
counter++;
t.setCounter(counter);
unitStock.addLast(t);
}
for (T t1 : unitStock) {
System.out.println(t1.getCounter());
}
}
return t;
}
}