so I have this class example:
public class Test {
private static int idCounter;
private int id;
Test() {
id=++idCounter;
}
public void getId() {
System.out.printf("This id is %s",this.id);
}
}
And the beans.xml config:
<beans>
<bean id="test" class="com.Test"/>
</beans>
Now when I try to make an ArrayList, the static variable resets every time.
for (int i=0;i<9;i++) {
arrayList.add(context.getBean("test");
arrayList.get(i).getId();
}
It will print that "This is is 1" for every object in the arrayList. How can I make it so that the static variable will keep it's global value?