Currently, we have learned about functions that have no return value and have no parameters.
Next is the function call, the function that needs the parameter should pass in the parameter when calling, the parameter type and quantity should be the same as the declaration.
The return value is primarily the return of a data after the function has finished executing.
Its main function is to separate the code of different functions into multiple parts, which is convenient for reusing the code.
Basic concepts of functions (methods)
(How to use, when to use)
public static void Main (String [] args) {}
Functions without parameters with return values
public static void XxxXxx1 () {
}
function with parameter without return value
public static void xxxXxx2 (int A, String s) {
}
function with parameter with return value
public static int xxxXxx3 (int A, String s) {
return 1;
}
public static String Draw (int x1,int y1, int x2, int y2) {
System.out.println ("line drawing ....");
Return "";
}
function (method) declaration and invocation in Java