void method java

Solutions on MaxInterview for void method java by the best coders in the world

showing results for - "void method java"
Issam
21 Sep 2019
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}
Andrea
06 Nov 2020
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}