Hey I'm a bit lost. I thought my code would do the following:
If a new low encountered then set secondMin as min then set min to X the new low. In reality tho my secondMin only stores the first value entered. Any hints?
package en.codegym.task.pro.task04.task0410;
import java.util.Scanner;
/*
Second smallest number entered
*/
public class Solution {
public static void main(String[] args) {
//write your code here
int min = Integer.MAX_VALUE;
int secondMin = Integer.MAX_VALUE;
Scanner console = new Scanner(System.in);
while (console.hasNextInt())
{int x= console.nextInt();
secondMin=min;
if (x<min)
{
min=x;
}
}
System.out.println(secondMin);
}
}