Methods in Java
A method can be defined as a collection of code which is referred to a name and it returns a value as it acts upon a given data.Each method has a unique name.
For method declaration it requires the method name,return type,modifiers used and the body of the method.
The general form of method is:
body of method
public void callSum()
int theSum = add(7, 3);
System.out.print("the sum is "+theSum);
public int add(int value1, int value2)
return value1 + value2;
the sum is 10
Advertisement Powered By Google Adsense
IF YOU LIKE THIS TUTORIALS PLEASE SHARE
java programming tutorial
learn java online
Object Oriented Language