Lets say I wanted to have the following prompt:
"Enter the number of iterations (400):"
Where, the user can enter an integer or simply hit enter for the default of 400.
How can I implement the default value in Java using the Scanner class?
public static void main(String args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of iterations (400): ");
input.nextInt();
}
As you can see, I must have "nextInt()", how can I do something like "nextInt or a return?", in which case if it is a return I'll default the value to 400.
Can anyone point me in the right direction?