泛型

day 7

泛型

装在集合当中的所有元素,全部统一的类型。泛型只能是 引用类型,使用基本类型需要装箱。

 

ArrayaList使用

建立:

ArrayList<String>list = new ArrayList<>;

注:对ArrayList来说,直接打印得到的是内容,不是地址数值,如果内容为空,得到空的[ ]。

新学到的方法:

boolean add(E e);//添加

E get(int index);//得到,下标为index的内容

E removed(int index);//移除下标为index的内容,并且返回删除的内容

基本类型包装类
byte Byte
short Short
int Integer
long Long
float Float
double Double
char Charater
boolean Boolean
原文地址:https://www.cnblogs.com/stydejava/p/13378968.html