레퍼런스변수, 배열문제
class Main {
public static void main(String[] args) {
int 자동차 = new 자동차;
자동차.달립니다();
}
}
class 자동차 {
void 달리다() {
System.out.println("자동차가 달립니다.");
}
}
정답
class Main {
public static void main(String[] args) {
자동차 자동차a = new 자동차();
자동차a.달리다();
}
}
리모콘을 변수에 저장하지 않고 바로 사용
문제 : 아래 코드가 실행되도록 해주세요.
class Main {
public static void main(String[] args) {
new 자동차().달리다();
}
}
class Main {
public static void main(String[] args) {
new 자동차().달리다();
}
}
class 자동차 {
void 달리다() {
System.out.println("달립니다.");
}
}