若想要Arraylist 存储数据,需要用基本类型对应的包装类
byte Byte
short Short
long Long
float Float
char Character
double Double
int Integer
boolean Boolean
Arraylist<Integer> list=new Arraylist<>();
例题:
定义个student类:string name;int age两个属性;
Arraylist <student> list=new Arraylist<>();
student s=new student("慌",20);
list.add(s);
list.get(s);