Opening Hours :7AM to 9PM
class ArrayLargestNumber { public int findLargest(int[] arr, int n) { int largest = Integer.MIN_VALUE; for (int i = 0; i < n; i++) { if (arr[i] > largest) { largest = arr[i]; } } return largest; } } public class Main { public static void main(String[] args) { ArrayLargestNumber aln=new ArrayLargestNumber(); int[] arr = {1, 14, 2, 16, 10, 20, 5}; int n = arr.length; int largest =aln.findLargest(arr, n); System.out.println("Largest element is " + largest); } }In this program, The findLargest method takes two arguments; the array, and the length of the array.