package chapter6;import java.util.*;public class demo3 { static public void main(String[] args) { Listnumlist=new ArrayList (); for(int i=0;i<20;i++) { int num = (int) (Math.random() * 100); numlist.add(String.valueOf(num)); } for(int i=0;i<20;i++) { System.out.print(numlist.get(i)+" "); } System.out.println("\n查找第几个数?"); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); System.out.println(numlist.get(n-1)); System.out.println("排序后:"); Collections.sort(numlist,new Comparator () { @Override public int compare(String o1, String o2) { if(Integer.valueOf(o1)>Integer.valueOf(o2)) { return 1; } return -1; } }); for(int i=0;i<20;i++) { for(int j=0;j<20;j++) { } } for(int i=0;i<20;i++) { System.out.print(numlist.get(i)+" "); } sc.close(); }}