0
Why is the error occurring? I've already initialized the variable.
4 Answers
+ 12
No, its never initialized! You have to assign a value to your variables first, try this :
int a = 0, b = 0, c = 0, count;
OR -- A variable gets itself initialized only if its declared static. Like if you make your int as static int then the initialized value would be 0.
+ 9
@Diwakar : Adding static keyword makes it a class variable, hence you have to declare it before the main() method.
static int a, b, c, count;
public static void main(String[] args) {
//...
}
You're welcome <3
+ 1
Thanks! It's working If i initialize them to 0. But when i use static, it is showing illegal start of expression.
+ 1
Thanks! It worked.