package jicheng;
import java.util.ArrayList;
import java.util.List;
public class jihelei {
public static void main(String[] args) {
List
//ArrayList后可不加
st.add(null); //允许重复,允许为空
st.add("Mike");
st.add(0,"Nancy"); //0指在指定位置插入,即Nancy,null,Mike
st.add("Nancy"); //Nancy,null,Mike,Nancy
st.add(4,"Jack"); //Nancy,null,Mike,Nancy,Jack (0-4)
System.out.println(st);
System.out.println(st.contains("Nancy")); //是否包含
System.out.println(st.get(4)); //返回列表中指定位置的元素
System.out.println(st.size());
System.out.println(st.isEmpty()); //是否为空
//======================================
//求某一字符中的字母个数,例如:aaaaa,1; abc,3;
String s = "wangdashun";
List
//ArrayList后可不加
for(int i=0;i
stc.add(s.charAt(i)); //依次插入不重复的字母
System.out.println(stc);
}
}
System.out.println(stc.size());
String h = "big data 2002 is very nice";
List
for(int i=0;i
if((h.charAt(i)>'A'&&h.charAt(i)<'Z'
||h.charAt(i)>'a'&&h.charAt(i)<'z')
&&!data.contains(h.charAt(i))){
data.add(h.charAt(i));
System.out.println(data);
}
}
System.out.println(data.size());
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)