JAVA不是带有?:if语句的语句

JAVA不是带有?:if语句的语句,java,Java,这行代码出现编译错误“nota statement”: parallel? stats[3]++ : stats[4]++; 不明白为什么 ?运算符用于返回值不是if/else的完全替代,并且您没有返回值。但是,请更好地解释什么是完全错误,并更好地查看代码,而不仅仅是您发布的行。引用: 显然,上面的代码行不属于上面提到的任何类别。因此,编译器抛出一个错误。看最外面的,而不是最里面的。提问者提供的详细信息量足以回答张贴的问题。 The following types of expressions

这行代码出现编译错误“nota statement”:

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

不明白为什么

?运算符用于返回值不是if/else的完全替代,并且您没有返回值。但是,请更好地解释什么是完全错误,并更好地查看代码,而不仅仅是您发布的行。

引用:


显然,上面的代码行不属于上面提到的任何类别。因此,编译器抛出一个错误。看最外面的,而不是最里面的。

提问者提供的详细信息量足以回答张贴的问题。
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.