Answers for "calling method 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
3

how to call a function in java

public class MyClass {
 
    static void myMethod() {
        System.out.println("You have called me! My name is: myMethod!");
    }
 
    public static void main(String[] args) {
        myMethod();
    }
}
Posted by: Guest on February-24-2021
3

java methods

public class MyClass {
  static int myMethod(int x) {
    return 5 + x;
  }

  public static void main(String[] args) {
    System.out.println(myMethod(3));
  }
}
// Returns 8
Posted by: Guest on June-02-2020

Code answers related to "calling method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language