Monday, 30 September 2013

Netbeans 7.3 misreports an "Unused assignment" hint

Netbeans 7.3 misreports an "Unused assignment" hint

Netbeans 7.3.1 IDE says that "The assigned value is never used" in the
indicated line of the following program:
public class JavaTest {
static int f() {
return Math.random() < 0.9 ? 0 : 1;
}
static int g() {
return Math.random() < 0.2 ? 0 : 1;
}
public static void main(String[] args) {
int ret;
while ((ret = f()) == 0) { // Unused assignment???
ret = g();
if (ret != 0)
System.out.println(ret);
}
System.out.println(ret);
}
}
I guess this is a bug in Netbeans, but can someone confirm if they have
seen it before?

No comments:

Post a Comment