wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Forward reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Forward reference" Watch "Forward reference" New topic
Author

Forward reference

Sam Zheng
Ranch Hand

Joined: Nov 29, 2000
Posts: 61
Reading through JLS, it seems that sometimes I can use some
sort of forward reference without causing compilation error.
One example from JSL is on page 21 of chapter 8. Relevant
part of the example is copied as below:
class UseBeforeDeclaration{
static{
x = 100; //ok
....
}
static int x;
}
However, I compile a simple example as the following and the
compiler is crying illegal forward reference:
class Test{
static{
x = 100;
}
static int x;
}
Can anyone help? What is going on here?
Thanks! Sam
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Forward reference
 
Similar Threads
Forward Reference
Again forward references
Nice question...answer for this
Static Block
forward reference doubt