public void max(int a,int b){
    if(a > b) System.out.println("A is bigger");
    else System.out.println("B is bigger");
}

Parameters allow you to pass values into a method. In the example above two values are passed in. The goal of the method is to decide which one of the values is bigger. A parameter is defined with a data type and name pair and will work in the same way as a normal variable.

You can use the parameters in the exact same way as variables. You can also assign values to parameters but it is not advisable as parameters are only meant to pass values in.

Most methods will represent a action or a process. The parameters represent the input to that process. The Obect orientation section will discuss how method are designed and created.

next return values

 
Basics
Menu
Search