[강좌] [JAVA] java case is between
하나를하더라도최선을
2019-10-25 12:22
3,168
0
본문
public static void main(String[] args) {
int num=(int)(Math.random() * 11);
if (isBetween(num, 1, 5)) {
System.out.println("testing case 1 to 5");
} else if (isBetween(num, 6, 10)) {
System.out.println("testing case 6 to 10");
}
}
public static boolean isBetween(int x, int lower, int upper) {
return lower <= x && x <= upper;
}
댓글목록0