- public class Test {
- public static void main(String[] args) {
- List<String> lst1 = new ArrayList<String>();
- List<String> lst2 = new ArrayList<String>();
- lst1.add("java01");
- lst1.add("java02");
- lst1.add("java03");
- lst1.add("java04");
- lst1.add("java05");
- ListIterator<String> it = lst1.listIterator();//[color=red]你的代码此处也要用泛型,否则他的next(),previous()方法返回值是Object[/color]
- while(it.hasNext()){
- System.out.print(it.next() + "\t");
- }
- System.out.println();
- while(it.hasPrevious()){
- String a = it.previous();
- lst2.add(a);
- System.out.print(a + "\t");
- }
- System.out.println();
- }
- }
复制代码 希望对你有帮助......
|