Method parameters and return values in JAVA classes, and return values of java Parameters
The public void method is used to declare a method without any parameters or return values;
The public void method is used to declare a method with no return value;
A method with a return value of a parameter is declared by using the public int method name (int I, int n) (int is the parameter's data type specified, or it can be another data type, for example: string, char, double, int ).
Instance:
// Define the class public class Test {// public void eat () {System. out. println ("I'm eating. ") ;}// Public void cheng (int I, int n) {System. out. println (I * n);} // public int getAge (int a) {return a;} public static void main (String [] args) {Test Myclass = new Test (); // create the object Myclass. eat (); // call the Myclass method. cheng (9,9); // call the method System. out. println (Myclass. getAge (18); // call method }}