Answers for "void function in java"

1

calling a void method java

public class methods{
  public static void main(String[] args){
    printSum(5, 15); // Print 20
  }
  public static void printSum(int a, int b){
    System.out.println(a + b);
  }
  // Our method should be outside the main methods bounds
  // Call your function inside the main method.
}
Posted by: Guest on June-18-2021
1

void method java

int a = 20;
int b = 20;
public static void sum(){ // Void Method
  System.out.println(a + b);
}
public static int sum(){ // Return Function
  return a + b;
}
Posted by: Guest on June-18-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language