2016-09-18 2 views
0

내가 코드 행에 대한 컴파일 오류 "아니 문"을 받고 있어요 경우 :JAVA하지와 문 : 문

parallel? stats[3]++ : stats[4]++; 

이유를 이해할 수 없다?!

답변

3

this에서 인용 :

The following types of expressions can be made into a statement 
by terminating the expression with a semicolon (;). 

Assignment expressions 
Any use of ++ or -- 
Method invocations 
Object creation expressions 

... 

In addition to expression statements, there are two other kinds of 
statements: declaration statements and control flow statements. 

은 물론, 코드의 당신의 라인은 위의 위의 언급 된 모든 범주에 해당하지 않습니다. 따라서 컴파일러에서 오류가 발생합니다. 가장 안쪽이 아닌 가장 바깥 쪽을보십시오.

4

:? 연산자가 사용 된 경우 값을 반환은 if/else에 대한 완전한 대체가 아니며 값을 반환하지 않습니다. 그러나 완전한 오류가 무엇인지 더 잘 설명하고 게시하는 코드뿐만 아니라 코드를 더 잘 살펴보십시오.