I tried compiling this code in Java:
class D
{
public static void main(String arg[])
{
f1();
}
static void f1()
{
int a;
int b=5;
for(;b<=10;b++)
a=b;
System.out.println(a);
}
}
But it generates an error that says: Variable 'a' might not have been initialized. Why is this happening, although a
is set in the for loop?