Why does the program give "illegal start of type" error?
124,638
Solution 1
You have a misplaced closing brace before the return
statement.
Solution 2
You have an extra '{' before return type. You may also want to put '==' instead of '=' in if and else condition.
Comments
-
David almost 2 years
here is the relevent code snippet:
public static Rand searchCount (int[] x) { int a ; int b ; int c ; int d ; int f ; int g ; int h ; int i ; int j ; Rand countA = new Rand () ; for (int l= 0; l<x.length; l++) { if (x[l] = 0) a++ ; else if (x[l] = 1) b++ ; } } return countA ; }
(Rand is the name of the class that this method is in)
when compiling it get this error message:
Rand.java:77: illegal start of type return countA ; ^
what's going wrong here? what does this error message mean?