switch
statements or expressions containing the same code in different branches
and suggests to merge the duplicate branches.
For example:
switch (n) {
case 1:
System.out.println(n);
break;
case 2:
System.out.println(n);
break;
default:
System.out.println("default");
}
Can be replaced with:
switch (n) {
case 1:
case 2:
System.out.println(n);
break;
default:
System.out.println("default");
}
New in 2019.1