Scanner sc = new Scanner(System.in); int minNum = Integer.MAX_VALUE - 1; int secondMin = Integer.MAX_VALUE; while (sc.hasNextInt()) { int income = sc.nextInt(); if (income < minNum) minNum = income; else if (income > minNum && income < secondMin) secondMin = income; } System.out.println(secondMin);