Collection存储字符串并遍历

Collection c=new ArrayList();
		
		c.add("abc");
		c.add("efg");
		c.add("fgh");
		
		//通过集合对象获取迭代对象
		Iterator it=c.iterator();
		while(it.hasNext()){
     
			String s=(String) it.next();
			System.out.println(s);
		}

你可能感兴趣的:(Java,java)