Answers for "what is a java method"

3

Methods in java

public class MethodExample
{
    public static void main(String args[])
    {
       printHi();
       int add = Addition(8, 3);
       System.out.println(add);
    }
    public static void printHi()
    {
       // This method has no return value
       System.out.println("Hi!");
    }
    public static int Addition(int a, int b)
    {
       // This method has a return value
       return a + b;
    }
}
Posted by: Guest on October-18-2021
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
0

method java

public class Main {
  public void fullThrottle() {
    System.out.println("The car is going as fast as it can!");
  }

  public void speed(int maxSpeed) {
    System.out.println("Max speed is: " + maxSpeed);
  }
}
Posted by: Guest on August-11-2021

Code answers related to "what is a java method"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language