When I enter a value that is in between than -2147483648 and 2147483647, the program closes and does not display the valid number like I wrote. If I enter a number outside the range, it is supposed to enter a while loop until I enter a valid number between the range. However when I enter a number outside the range it simply displays an exception error, which is why I put the catch there in the 1st place.
I have tried this problem for a few hours now, I am still relatively new to coding (2nd class) so I am sorry if this has been answered before. I looked up a lot of the older answers and tried to use that as a model for my code. However this is as far as I got.
import javax.swing.JOptionPane;
public class test
{
public static void main (String[] args) throws NumberFormatException
{
String input;
boolean x;
int number;
while (x = false)
{
try
{
input = JOptionPane.showInputDialog("Enter an integer: "); //creates input box for user to enter integer value
number = Integer.parseInt(input);
if ( number < -2147483648 && number > 2147483647)
x = false;
else
{
x = true;
System.out.println("You entered: " + number);
}
break;
}
catch (NumberFormatException e)
{
continue;
}
}
}
}