
Java Class Method
Java Class Method
Methods are set of executable codes , which have implemented with and without return type. Method will return the value based on the use case.
Example:
package dkp.week3; public class MethodExample { public static void sumNumber1(int a,int b) { System.out.println("Void Method"+(a+b)); } public static int sumNumber2(int a,int b) { return(a+b); } public static void main(String[] args) { // TODO Auto-generated method stub int c; c=sumNumber2(10,20); System.out.println("Int Method:"+c); sumNumber1(10,20); } } |
Sample output:
Int Method:30 Void Method30 |