- import java.util.*;
- class ListDemo
- {
- public static void main(String[] args)
- {
- List<String> list = new ArrayList<String>();
- Collections.addAll(list,"aaa","bbb","ccc");//将你添加数据的代码改为这一句了,效果一样
- Iterator it = list.iterator();
- String s ="";
- while(it.hasNext())
- {
- s+=it.next()+" ";
- }
- System.out.println(s);
- }
- }
复制代码
|
|