Hi guys, pls gimme a hint.

package en.codegym.task.pro.task04.task0410;
import java.util.Scanner;
/*
Second smallest number entered
*/
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
while (scanner.hasNextInt()){
int x = scanner.nextInt();
if ( x < min ) {
min = x;
} else {
max = x;
}
}
if (min < max){
min = max;
}
System.out.print(min);
}
}

At least two numbers must be entered. If less than two integers are entered, then terminate the program with an error. You don't need to handle this situation.It says this program MUST have 2 numbers entered in the very beginning. This would be logical to have them entered prior to the loop. If something other than a number is entered for those 2 then the program should end with an error. The code you shared still does not do this. When I entered one or no numbers it still outputs-2147483648. #2 This code now only works when entering 2 numbers at a time. Anytime I enter an odd amount of numbers the loop breaks because of line 8 and the previously entered number is lost. For example, if I entered:3 2 1 *end*The entered1would be read in at line seven and then line8would be true because of the entered*end*and the1would be lost. #3 'firstMin' is never used. You could remove lines 3, 15, 19 with no effect to the code. Looking at the algorithm it would seem this is to save the value minimum entered number up until that point. Since it isn't being used that way there are logical errors in the algorithm. #4 Line 17 is breaking the loop if the number entered for line 12 is greater than the number entered for line 7.At least two numbers must be entered. If less than two integers are entered, then terminate the program with an error. You don't need to handle this situation."1 2 3 4 5 6 *end*The last number is 6. The code would determine the minimum of the previous numbers (which is 1), compare that to the last of 6, and then output the greater of those two, which is 6 (correct output would be 2). If you entered:6 4 2 5 3 9 7 *end*The last number is 7 and the minimum of the previous entries is 2, so 2 and 7 are compared and the code outputs 7 (correct output would be 3) So the only case where it works is if the last entered number is the actual second to smallest number. In all other cases it outputs the incorrect result.2 *end*(should error out)1 2 *end*(should output 2)2 2 *end*(outputs 2)3 3 2 *end*(outputs 3)2 2 3 *end*(outputs 3)1 1 12 5 8 1 10 20 4 1 15 21 *end*(outputs 4)3 5 6 2 4 3 1 *end*(outputs 2)