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