When I try to compile this:
public static Rand searchCount (int[] x) { int a ; int b ; ... for (int l= 0; l<x.length; l++) { if (x[l] == 0) a++ ; else if (x[l] == 1) b++ ; } ... }
I get the following errors:
Rand.java:72: variable a might not have been initialized a++ ; ^ Rand.java:74: variable b might not have been initialized b++ ; ^ 2 errors
It seems to me that I initialized them at the top of the method. What is going wrong?
java variables initialization
David Mar 15 '10 at 16:45 2010-03-15 16:45
source share