영어로 읽는 코딩

17_[자바] ++

Auto increment and decrement

 

There are two versions of each type of operator, often called the prefix and postfix versions. Preincrement means the ++ operator appears before the variable, and post-increment means the ++ operator appears after the variable. Similarly, pre-decrement means the -- operator appears before the variable, and post-decrement means the -- operator appears after the variable. For pre-increment and pre-decrement (i.e., ++a or --a), the operation is performed and the value is produced. For post-increment and post-decrement (i.e., a++ or a--), the value is produced, then the operation is performed.

 

……

 

You can see that for the prefix form, you get the value after the operation has been performed, but with the postfix form, you get the value before the operation is performed.

 

 

[Thinking in Java, 69]

댓글

댓글 본문
버전 관리
Yoo Moon Il
현재 버전
선택 버전
graphittie 자세히 보기