Java Program to find the Maximum of n numbers passed from command line argument…

This java program will find the greatest number from given n numbers passed from command line argument
class Max_cmd
{
                public static void main(String args[])
                {
                                int a,i,max;
                                max=Integer.parseInt(args[0]);
                                for(i=1;i
                                {
                                                a=Integer.parseInt(args[i]);
                                                if(a>max)
                                                {
                                                                max=a;
                                                }
                                }
                                System.out.println(“THe maximum of “+args.length + ” numbers is “+max);
                }

}

Add Comment