if
、while
、for
或
do
语句的条件,或在任何其他情况下的赋值。
虽然有时是有意为之,但这种用法会引起混淆,并且可能表明存在拼写错误(例如,应使用 =
而不是 ==
)。
快速修复会将 =
替换为 ==
。
示例:
void update(String str, boolean empty) {
// 警告:'empty' 被重新赋值,
// 不与 str.isEmpty() 进行比较
if (empty = str.isEmpty()) {
...
}
}
在应用快速修复后:
void update(String str, boolean empty) {
if (empty == str.isEmpty()) {
...
}
}