R
Razvan
Hi !
In the following code:
public class CDummy
{
static {
jj = 5;
// System.out.println("jj=" + jj);
}
public static void main(String args[])
{
System.out.println("CDummy.");
System.out.println("jj = " + jj);
}
static int jj = 6;
}
I can assign to the primitive jj the value 5 even if the primitive is
defined later, however I cannot print its value because I use a
'forward reference' ! Can somebody explain why I can do
jj = 5;
but I cannot do
System.out.println("jj=" + jj);
I think that I should either have access to jj prior to declaration +
definition (line: static int jj = 6
in both cases or the access
should be denied in both cases. If there is a logical explanation for
this I would like to hear it.
Regards,
Razvan
In the following code:
public class CDummy
{
static {
jj = 5;
// System.out.println("jj=" + jj);
}
public static void main(String args[])
{
System.out.println("CDummy.");
System.out.println("jj = " + jj);
}
static int jj = 6;
}
I can assign to the primitive jj the value 5 even if the primitive is
defined later, however I cannot print its value because I use a
'forward reference' ! Can somebody explain why I can do
jj = 5;
but I cannot do
System.out.println("jj=" + jj);
I think that I should either have access to jj prior to declaration +
definition (line: static int jj = 6
should be denied in both cases. If there is a logical explanation for
this I would like to hear it.
Regards,
Razvan