Answers for "function and method in java"

10

java method

public class Main {
  public static void main(String args[]) {
    SayHi();
    
    int sum = AddNums(5, 6);
    System.out.println(sum);
  }
  
  public static void SayHi() { //This method has no return value
    System.out.println("Hi!");
  }
  
  public static int AddNums(int a, int b) { //This method has a return value
    return a + b;
}
Posted by: Guest on December-20-2019
1

method/function in java

public class Main {
  static void myMethod() {
    // code to be executed
  }
}
Posted by: Guest on July-04-2021

Code answers related to "function and method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language