From a quick review of that block :
while(a!=0){
...
else if(a==2)
{d=new User_Interface2();
d.showData();}
else if(a==3)
{d=new User_Interface2();
d.main();}
}
You are creating a new instance on each iteration.
Create d
outside the loop and reuse that instance.
d=new User_Interface2();
while(a!=0){
...
else if(a==2) {
d.showData();
} else if(a==3) {
d.main();
}
}
solved ArrayList is reinitialising when a method is called