mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-20 11:36:16 +07:00
Otherwise String.length() matches to every field which results in warning every time field is checked for negative value after assignment
19 lines
400 B
Java
19 lines
400 B
Java
class FieldReassignInt {
|
|
void test() {
|
|
Holder res = new Holder();
|
|
int pos = getSomething();
|
|
if (pos == -1) System.out.println("oops");
|
|
res.position = pos;
|
|
if (pos == -1) System.out.println("oops");
|
|
if (res.position == -1) System.out.println("oops");
|
|
System.out.println(res);
|
|
}
|
|
|
|
static class Holder {
|
|
int position;
|
|
}
|
|
|
|
int getSomething() {
|
|
return 42;
|
|
}
|
|
} |