강의

멘토링

커뮤니티

Inflearn Community Q&A

kys9603133643's profile image
kys9603133643

asked

Mastering Java Basics with Teacher Eun-jong (Do it! Introduction to Java Programming) - Part 1 (Basics)

Polymorphism and the reasons for using it

static 메서드 main문 안에 선언 시 오류 발생 이유가 궁금합니다.

Written on

·

380

0

안녕하세요

객체지향 핵심 섹션 5에서 6번째 강의 다형성과 다형성을 사용하는 이유를 듣는데

첫 번째 실습 예제 중에 static으로 선언하는 animalMove 메서드를 main문 안에 적었더니

'void is an invalid type for the variable animalMove' 라는 오류가 발생했는데

main문 안에 선언하면 안되는 이유가 궁금합니다.

java객체지향

Answer 1

1

eunjong님의 프로필 이미지
eunjong
Instructor

메서드를 main() 메서드 내부에 넣으시는건 자바 문법에서 허용하지 않습니다.

kys9603133643's profile image
kys9603133643

asked

Ask a question