Problem description:
In this Java code, the try { } block is properly indented, the catch { } block is not indented, it lines up with the catch block
Expected behavior:
Consistent indentation in try and catch blocks
Actual behavior:
See below - the catch block code lines up with the keyword, it should be indented
Steps to reproduce:
Wrote this code. I’d be interested to hear if anyone else has the same problem, or is it just my repl. [It’s in a Teams for Education repl, so I can’t post a public link, sorry.]
public static void demoTryCatch() {
final double ADULT_FARE = 25.00;
final double REDUCED_FARE = 15.00;
try {
Scanner scan = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = scan.nextInt();
double fare = (age >= 18 && age <= 65) ? ADULT_FARE : REDUCED_FARE;
} catch (InputMismatchException ime) {
System.out.printf("Please enter a whole number (%s)\n", ime.getMessage());
}
System.out.println("And the program keeps going ...\u263A");
}
}
Bug appears at this link:
Browser/OS/Device: