Programmer Coding

Java -Way(method)

A Java way(method) is a set of statements that are grouped together to apply an operation.
When you call the System.out.println() way(method) , for example, the system actually applys
some statements in order to display a message on the console.
Now you will learn how to produce your own way(method) s with or without return values,
produce away(method) with or without parameters, and apply way(method) conceptualion
in the program design.
Creating Way(method)
Considering the following example to explain the syntax of a way(method) −
Syntax

public static int methodName(int a, int b) {
// body
}

Here,
1. public static − modifier
2. int − return type
3. way(method) Name − name of the way(method)
4. a, b − formal parameters
5. int a, int b − list of parameters
Way(method) definition consists of a way(method) header and a way(method) body. The
same is shown in thefollowing syntax −
Syntax

modifier returnType progemar (Parameter List) {
// method body
}

The syntax shown above includes −

1. modifier − It bounds the entrance type of the way(method) and it is optional to use.
2. returnType − Way(method) may return a value.
3. nameOfWay(method) − This is the way(method) name. The way(method) signature consists of the way(method) name and the parameter list.

1. Parameter List − The list of parameters, it is the type, order, and number of parameters
of a way(method) . These are optional, way(method) may store(contain) zero
parameters.
2. way(method) body − The way(method) body bounds what the way(method) does with the
statements.

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top