I am new to Java and I have been searching for 2 days how to accomplish this and still have not figured it out. In my if statement I need to ensure that if a user just presses enter with out entering a value a message will prompt for re entry, also if the user enters a value less than 1. Below is a snip of my code. I have read the int cant except null, and I have tried Integer , BUT my code wont run with that
int numberOfCars = -1
while (numberOfCars == null || numberOfCars < 1)
{
numberOfCars = (JOptionPane.showInputDialog("Enter number of cars."));
if(numberOfCars == null || numberOfCars < 1)
{
JOptionPane.showMessageDialog(null, "Please enter a value.");
}
}