Java Practice Source code on the keyboard randomly input n numbers in the list to output its results from large to small!

Source: Internet
Author: User

/*

* 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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.