Use of the return value method with a parameter in Java
If the method contains both parameters and return values, we are called methods with the return value of the parameter.
For example: The following code, which defines a show method with a parameter name, returns a String result after the method executes
650) this.width=650; "style=" width:340px; src= "Http://img.mukewang.com/537dce1e0001b09305200123.jpg"/>
Call a method with a parameter return value:
650) this.width=650; "style=" width:340px; src= "Http://img.mukewang.com/537dce3e0001226f04870138.jpg"/>
Operation Result: 650) this.width=650; "src=" http://img.mukewang.com/537dcf090001068401350025.jpg "/>
Code:
Import Java.util.Arrays;
public class HelloWorld {
public static void Main (string[] args) {
HelloWorld Hello = new HelloWorld ();
Int[] scores={79,52,98,81};
Call the method, pass in the score array, and get the number of scores
int Count=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 (arrays.tostring (scores));
Returns the number of elements in an array
return scores.length;
}
}
Operation Result:
[52, 79, 81, 98]
A total of 4 results information!
This article is from "Ghost" blog, please make sure to keep this source http://caizi.blog.51cto.com/5234706/1548009
Java Basics---The use of method with parameter return values in Java (40)