Read the JLS rules about forward referencing,that will clear up all your doubts.
Compiler issues forward referencing errors only when it is being used in initializers(static or instance)
Eg:
int i=j;
int j=20;
will give a compile time error,because j variable cant be accesed in initializer statement of i.
Similarly,
int i;
{
i=j;
}
int j=20;
will give a compiler error.
However,if a method is used,then there will be no compiler error and the default value of the variable will be taken.Eg
int i=j();
public int j()
{
return j;
}
int j=10;
Here,the value 0 will be assigned to i.
Because the default value of int is 0.
This topic has been discussed a lot of times in this forum,use the javaranch's search facility.
And I repeat,see JLS for a very clear understanding on this topic.
[note:There is a bug in the
java language related to forward referencing in which the java compiler does not act as specified in JLS.Consult sun's website for it]
Thanks
Gautam