Scanner console = new Scanner(System.in); int min = Integer.MAX_VALUE; int secondMin = Integer.MAX_VALUE; while (console.hasNextInt()) { int tmp = console.nextInt(); if (tmp < min) { secondMin = min; min = tmp;(Зачем они нужны?)