Method in java, Simple method Example other than main

Java Programming Language Class, Object and Methods in java (Article) Class, Object and Methods in java (Program)

1081

Program:

 public class MinAmongTwoNumber {

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

   /** returns the minimum of two numbers */
   public static int minFunction(int n1, int n2) {
      int min;
      if (n1 > n2)
         min = n2;
      else
         min = n1;

      return min;
   }
}

Output:

Minimum Value = 30
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.