i have class in which i declare a static variable id
class id
{
private static int id;
public int getid()
{
return this.id
}
public void setid(int id)
{
this.id=id;
}
}
i have another class in which i create the object of this class and call these methods
class abc
{
id obj=new id();
int a=obj.getid();
obj.setid(a+1);
}
now i am storing it to an static ArrayList in another class
class ser
{
private static ArrayList<id>al=new ArrayList<id>();
public static addid(id obj)
{
al.add(obj);
}
}
now the problem is that it replaces the object every time i add the object to the list what is the error please help