Function call in Java

Source code :

public class MinFunction
{
   
   public static void main(String[] args) {
      int a = 11;
      int b = 6;
      int c = minFunction(a, b);
      System.out.println("Minimum Value = " + c);
   }

   public static int minFunction(int n1, int n2) {
      int min;
      if (n1 > n2)
         min = n2;
      else
         min = n1;

      return min; 
   }
}

Output :

Minimum Value = 6  

Algorithm :

  1. Initialize the function name and variables
  2. Call the function with name of the function
  3. Perform the operation
  4. print the result

Output :


                

Comments :