基本上是java的新学习者,只能通过自我阅读。希望对此代码有所帮助。感谢名单
public class retrievelist{
public static void main(String[] args){
StoreList a=new StoreList();
for(int j=0;j<3;j++){
a.addData(j, "joe");
}
System.out.println(a.data.size());
for(int i=0;i<a.data.size();i++){
System.out.println(a.getdata(i));
}
}
}
StoreList.java
import java.util.ArrayList;
public class StoreList {
private int id;
private String first;
ArrayList<StoreList> data=new ArrayList<StoreList>();
public void addData(int id,String first){
StoreList info=new StoreList();
info.id=id;
info.first=first;
data.add(info);
}
public ArrayList getdata(){
return data;
}
}
当我运行此代码时,我得到类似的东西 StoreList @ 2a717ef5