Answers for "what is a method in java programming"

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

Code answers related to "what is a method in java programming"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language