Skip to content

구문(Statement) 와 표현식(expression) 의 차이? #25

Discussion options

You must be logged in to vote

각각의 정의를 간단하게 알고 있으면 도움이 될 것 같아 저도 이번 기회에 정리해 봤습니다.

  • 식(expression): 하나 이상의 값(value)을 반드시 산출(produce)할 수 있는 코드
  • 문(statement): 무언가를 수행(action)할 수 있는 코드 블록; 실행할 수 있는(executable) 최소 표현식

식은 표현식이라고도 하며, 리터럴이나 연산자의 조합으로 만들어집니다.
그래서 statementexpression 의 부분 집합으로 좀 더 큰 범주에 속합니다.

System.out.println(String) 은 입력받은 문자열을 출력할 수 있는 statement 이며,
return 예약어가 없다면 void 타입으로 Consumer<T> 등의 함수형 인터페이스를 사용할 수 있습니다.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Irisation23
Comment options

Answer selected by Youngju-Jang
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Youngju-Jang 영주님을 위한 라벨입니다.
4 participants