1public class methods{
2 public static void main(String[] args){
3 printSum(5, 15); // Print 20
4 }
5 public static void printSum(int a, int b){
6 System.out.println(a + b);
7 }
8 // Our method should be outside the main methods bounds
9 // Call your function inside the main method.
10}
1int a = 20;
2int b = 20;
3public static void sum(){ // Void Method
4 System.out.println(a + b);
5}
6public static int sum(){ // Return Function
7 return a + b;
8}