switch
package sec04.chap02;
public class Ex01 {
public static void main(String[] args) {
int fingersOut = 2;
// ๐ก switch : ๊ดํธ ์์ ๊ธฐ์ค์ด ๋ ๋ณ์๋ฅผ ๋ฐ์
// ๊ฐ๋ฅํ ์๋ฃํ: byte, short, int, char, String, enum(์ดํ ๋ฐฐ์)
switch (fingersOut) {
// ๐ก case : ๊ธฐ์ค์ ์ผ์นํ๋ case๋ก ๋ฐ๋ก ์ด๋
// ๐ก break : switch๋ฌธ ์คํ์ ์ข
๋ฃ
// ๐ก default: ํด๋นํ๋ case๊ฐ ์์ ๋ - ๋ง์ง๋ง์ ์์ฑ
case 2:
System.out.println("๊ฐ์");
break;
case 0:
System.out.println("๋ฐ์");
break;
case 5:
System.out.println("๋ณด");
break;
default:
System.out.println("๋ฌดํจ");
}
}
}
Last updated