/*
* Randomly enter n numbers on the keyboard to the list to output their results from large to small
*/
public class Test01 {
public static void Main (string[] args) {
List list1=new ArrayList ();
Integer cnt=0;
for (int i=0;i<args.length;i++)
{List1.add (Cnt.parseint (Args[i]))//string converted to integer and deposited in List1
}
System.out.println (List1);
Collections.sort (List1);//the sort () natural sort method that invokes the tool class;
Collections.reverse (List1);//tool class inversion function reverse ();
SYSTEM.OUT.PRINTLN ("* * after reversal * *");
System.out.println (List1);
}
}
This is used in the main () method args[] Input:
The first step is to right-click the interface as shown: (Follow the steps)
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4D/3B/wKiom1ROBzKzlpUbAANGdcTVocs845.jpg "style=" float: none; "title=" Image 1.png "alt=" Wkiom1robzkzlpubaangdctvocs845.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4D/3C/wKioL1ROB4fABtgXAAMcKt1ki8s833.jpg "style=" float: none; "title=" Image 2.png "alt=" Wkiol1rob4fabtgxaamckt1ki8s833.jpg "/>
Java Practice Source code on the keyboard randomly input n numbers in the list to output its results from large to small!