VOOZH about

URL: https://www.geeksforgeeks.org/java/java-method-parameters/

⇱ Java Method Parameters - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Method Parameters

Last Updated : 23 Jul, 2025

Parameters are variables defined in the method declaration after the method name, inside the parentheses. This includes primitive types such as int, float, boolean, etc, and non-primitive or object types such as an array, String, etc. You can pass values(Argument) to the method parameters, at the method call. The method call has the same number of arguments and is in the same order, as the parameters. To know more, refer to the article Difference between Parameters and Arguments.

The following example has a method example that takes a String as a parameter and returns a String type value.


Output
Hello GFG!

The above example static method has only one parameter. You can add many different types of parameters but java gives a limit, the limit says you can add 255 parameters or less. All primitive or non-primitive types take one unit of parameter length, except long and double. long or double takes two units of parameter length. The total length of parameters is calculated by the sum of the total units of all parameters.

Note: long or double takes two units of parameter length, hence you can add only 127 parameters of this type.

The Basic Syntax is:

public static String methodSyntax(int a0, int a1 .... int a253, int a254) {
 return "Method Executed";
}

The following example has a static method that takes 255 parameters of type int and we pass 255 arguments in a method. The method returns a String value which tells us, there is no error.


Output
Method Executed

Note: When we talk about the non-static method, the non-static method accepts only 254 parameters.

Comment
Article Tags:
Article Tags: