package pkgswitch;
import java.util.Scanner;
public class Switch {
public static void main(String[] args) {
double subtotal = 0.0;
Scanner sc = new Scanner(System.in);
outerloop:
while(0==0){
System.out.print("Enter subtotal: ");
if (sc.hasNextDouble())
{
subtotal=sc.nextDouble();
}
else
{
sc.nextLine();
System.out.println("Error!");
continue outerloop;
}
}
}
}
I'm working with learning how to catch exceptions. (I know about the try
/ catch
)
Question:
How does scanner have more double tokens when it has just been initialized with no input