It produces the correct result. Can anyone advise on this or give me advice
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> a = new ArrayList<Integer>();
int[] array = new int[20];
int maximum = 0;
int minimum = 0;
int index = 0;
int min = array[0];
int max = array[0];
//get min of an array
for (int i = 0; i < array.length; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
for (int i = 0; i < array.length; i++) {
if (array[i] < min){
min = array[i];
minimum = min;
}
}
for (int i = 0; i < array.length; i++) {
if (array[i] > max){
max = array[i];
maximum = max;
}
}
System.out.print(maximum + " " + minimum);
}
}
package com.codegym.task.task07.task0721;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Array;
import java.util.ArrayList;
import java.util.Arrays;
/*
Min and max in arrays
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> a = new ArrayList<Integer>();
int[] array = new int[10];
int maximum = 0;
int minimum = 0;
int index = 0;
int min = array[0];
int max = array[0];
//get min of an array
for (int i = 0; i < array.length; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
for (int i = 0; i < array.length; i++) {
if (array[i] < min){
min = array[i];
minimum = min;
}
}
for (int i = 0; i < array.length; i++) {
if (array[i] > max){
max = array[i];
maximum = max;
}
}
System.out.print(maximum + " " + minimum);
}
}