Skip to content

Instantly share code, notes, and snippets.

@akimicyu
Created July 16, 2014 13:14
Show Gist options
  • Save akimicyu/cd805226cfafca6fe523 to your computer and use it in GitHub Desktop.
Save akimicyu/cd805226cfafca6fe523 to your computer and use it in GitHub Desktop.
public class SwitchTest2 {
public static void main(String[] args) {
int n = -1; // ここ変えてください。
switch (1 + n * n) {
case 0:
if (n > 0) {
System.out.println("0A");
} else {
System.out.println("0B");
}
break;
case 1:
if (n > 0) {
System.out.println("1C"); // <- ここに行くためのn
} else {
System.out.println("1D");
}
break;
case 2:
if (n > 0) {
System.out.println("2E");
} else {
System.out.println("2F");
}
break;
default:
System.out.println("それ以外");
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment