Hello, why is my code wrong according to the test? When I run it works correctly. Thank you.
package com.codegym.task.task07.task0721;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Min and max in arrays
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int minimum;
int maximum;
//write your code here
int[] listArray = new int[20];
for (int i = 0; i < 20; i++) {
listArray[i]=(Integer.parseInt(reader.readLine()));
}
maximum = listArray[0];
minimum = listArray[0];
for (int i = 0; i < listArray.length - 1; i++) {
if (listArray[i] < minimum) {
minimum = listArray[i];
}
if (listArray[i] > maximum) {
maximum = listArray[i];
}
}
System.out.print(maximum + " " + minimum);
}
}
package com.codegym.task.task07.task0721;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Min and max in arrays
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int minimum;
int maximum;
//write your code here
int[] listArray = new int[20];
for (int i = 0; i < 20; i++) {
listArray[i]=(Integer.parseInt(reader.readLine()));
}
maximum = listArray[0];
minimum = listArray[0];
for (int i = 0; i < listArray.length - 1; i++) {
if (listArray[i] < minimum) {
minimum = listArray[i];
}
if (listArray[i] > maximum) {
maximum = listArray[i];
}
}
System.out.print(maximum + " " + minimum);
}
}