Thursday, 25 August 2022

Max value in array


 public class HelloWorld{


     public static void main(String []args){

        System.out.println("Hello, World!");

        int arry[] = new int[]{1,2,33,33,6,6};

        int max = arry[0];

          for(int i=1; i<arry.length;i++){

                 if(arry[i]> max){

                     max = arry[i];

                 }

            

         }

          System.out.println("Hello, World!"+max);

     }

}

No comments:

Post a Comment