public class CollectionDemo4 {
public static void main(String[] args) {
//创建集合对象
Collection c=new ArrayList();
//添加字符串元素
c.add("hello");
c.add("qwe");
c.add("cvb");
//遍历
Object ob[]=c.toArray();//向上转型
for(int x=0;x<ob.length;x++) {
String s=(String)ob[x];
System.out.println(s+"-"+s.length());
}
}
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交