import java.util.*;public class Test
{
public static void main(String[] args)
{
List<Integer> ints=new ArrayList<Integer>();
Integer[] s={1,2,2,4,5,5};
Collections.addAll(ints,s);
List<Integer> secound=new ArrayList<Integer>();
Collections.addAll(secound,s);
ListIterator<Integer> t=ints.listIterator();
while(t.hasPrevious())
secound.add(<Integer>t.previous());
System.out.println(secound);
}
}
为什么不能输出想要的答案????
{
public static void main(String[] args)
{
List<Integer> ints=new ArrayList<Integer>();
Integer[] s={1,2,2,4,5,5};
Collections.addAll(ints,s);
List<Integer> secound=new ArrayList<Integer>();
Collections.addAll(secound,s);
ListIterator<Integer> t=ints.listIterator();
while(t.hasPrevious())
secound.add(<Integer>t.previous());
System.out.println(secound);
}
}
为什么不能输出想要的答案????
while(t.hasNext()) {
second.add(t.next());才对吧。
}如果你想逆序用ints.listIterator(ints.size());