Use of the return value method with a parameter in Java

Source: Internet
Author: User

public class Mains {

public static void Main (string[] args) {

Mains hello = new mains ();

Int[] scores={79,52,98,81};

Hello.sort (scores);

System.out.println ("First" +hello.sort (scores));

Call the method, pass in the score array, and get the number of scores

int count= Hello.sort (scores);

System.out.println (Hello.sort (scores));

System.out.println ("A total of" +count+ "score information! ");

}

/*

* Function: Sort and output the exam results, return the number of results

* Defines a method that contains an integer array parameter, passing in an array of scores

* Use the Arrays class to sort the result array and output

* Returns the number of elements in the array after the method executes

*/

public int sort (int scores[]) {

Arrays.sort (scores);

System.out.println ("Second" +arrays.tostring (scores));

Returns the number of elements in an array

return 1;

}

}


Use of the return value method with a parameter in Java

Related Article

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.