我把你的代码改了下:- import java.util.*;
- class aaa
- {
- public static void main(String[] args)
- {
- Integer[] a = {0,15,-14,45,20,70};
- List<Integer> ls = Arrays.asList(a);
- Collections.reverse(ls);
- StringBuilder sb = new StringBuilder();
- Iterator<Integer> it = ls.iterator();
- while (it.hasNext())
- {
- Integer itg = it.next();
- sb.append(itg+",");
- }
- System.out.println(sb);
- String arr[]={"aaa","bbb","ccc"};
- List <String> ls1 = Arrays.asList(arr);
- Collections.reverse(ls1);
- StringBuilder sb1 = new StringBuilder();
- Iterator<String> it1 = ls1.iterator();
- while (it1.hasNext())
- {
- String itg = it1.next();
- sb1.append(itg+",");
- }
- System.out.println(sb1);
-
- }
- }
复制代码 |