Answers for "what do methods do 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
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 "Java"

Java Answers by Framework

Browse Popular Code Answers by Language