boolean을 반환하는 메서드를 만들면 조건을 이름으로 표현할 수 있습니다.
boolean
static boolean isEven(int n) { return n % 2 == 0; }
n % 2 == 0 자체가 이미 참·거짓이므로 if 없이 바로 돌려줄 수 있습니다.
n % 2 == 0
if
isAdult 메서드를 만드세요 (나이를 받아 19 이상이면 true)
public class Main { // isAdult 메서드를 만드세요 (나이를 받아 19 이상이면 true) public static void main(String[] args) { System.out.println(isAdult(20)); } }