```
package com.company;
import java.util.*;
public class Main {
public static int Largest(int array[]) {
    int largest = Integer.MIN_VALUE;
      for (int i = 0; i <= 5; i++) {
         if (array[i] > largest) {
            array[i] = largest;
        }
        System.out.println(largest);
    }
    return largest;
}

     public static void main(String[] args) {
    // write your code here
    Scanner sc = new Scanner(System.in);
    int array[] = new int[5];
    for (int i = 0; i <= 5; i++) {
        array[i] = sc.nextInt();
        System.out.println(array[i]);

    }
    Largest(array);
    System.out.println("largest element is : "+Largest(array));

}

```

}

This is the code to find the largest no. in an array but the output I'm getting for this code isn't desirable. Please check and let me know the problems in this code.