Array Question 2

Home / Java Practice Question / Array Question 2

Array Question 2


Question 2 .Write a program to find largest element in array.

Program- 


class Compute {  

    public int largest(int arr[], int n)

    { int max=arr[0];

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

        if(arr[i]>max){

            max=arr[i];

        }

    }

    return max;       

    }

}