Community
Participate
Working Groups
Snippet switch (string) { case "one": System.out.println("Accept"); return true; case "two": System.out.println("Unsure"); return true; default: System.out.println("Fail"); return false; } 1. Select the string "two" in second case statement 2. Press Ctrl + 1 and invoke extract to local variable The result is switch (string) { case "one": System.out.println("Accept"); return true; String string2 = "two"; case "two": System.out.println("Unsure"); return true; default: System.out.println("Fail"); return false; } problem: 1. the statement 'String string2 = "two";' should be placed outside the scope of Switch 2. The string "two" should have been replaced by string2 variable (even though that is wrong and would have compile error)
> 1. the statement 'String string2 = "two";' should be placed outside the scope > of Switch Makes sense. > 2. The string "two" should have been replaced by string2 variable (even though > that is wrong and would have compile error) This is bug 100871. *** This bug has been marked as a duplicate of bug 100871 ***
Note that the declaration was put at the right location in 3.3 and older.