Saturday, November 5, 2022

ONE DIMESNISINAL ARRAY

 


public class SCArray1 

{

    public static void main(String[] args) 

    {

        int A[]={3,9,7,8,12,6,15,5,4,10};

        int max1,max2;

        max1=max2=A[0];

        for(int i=0;i<A.length;i++)

        {

            if(A[i]>max1)

            {

                max2=max1;

                max1=A[i];

            }

            else if(A[i]>max2)

            {

                max2=A[i];

            }

        }

        System.out.println("Second Largest is "+max2);

        

    }   

        

    }

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...