Saturday 18 August 2012

Java Program to find Maximum of 2 Numbers


Java Program to find Maximum of 2 numbers:
Class MaxNo{
  public static void main(String args[]){
      //taking value as command line argument.
      //Converting String format to Integer value
      int n1 = Integer.parseInt(args[0]);
      int n2 = Integer.parseInt(args[1]);
      if(n1 > n2)
          System.out.println(n1+" is greater than "+n2);
      else
          System.out.println(n2+" is greater than "+n1);
  }
}

No comments:

Post a Comment