Проверял с отриц. числами в IDE и с другим набором
package com.javarush.task.pro.task04.task0410;
import java.util.Scanner;
/*
Второе минимальное число из введенных
*/
public class Solution {
public static void main(String[] args) {
Scanner console = new Scanner (System.in);
int realMin = Integer.MAX_VALUE;
int secondMin = Integer.MAX_VALUE;
int counter = 0;
int x;
while(console.hasNextInt()){
x = console.nextInt();
if(x < realMin){
realMin = x;
} else if (x > realMin && x < secondMin && x != secondMin){
secondMin = x;
}
counter++;
}
if (counter < 2){
System.out.println("Error");
}
if (counter > 1){
System.out.println(secondMin);
}
}
}