This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Forward references... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Forward references..." Watch "Forward references..." New topic
Author

Forward references...

Neil Mac
Greenhorn

Joined: Oct 03, 2003
Posts: 7
The Mughal Java cert book I'm currently studying states that
"An instance initializer cannot make forward rererences to member varibles declared after the initializer"
However, the following code compiles and runs fine....
public class Driver{
{
att2 = false;
}
private boolean att2 = true;
...
...

The only difference I can see is that the book refers to Java 1.2 but the compiler I'm using is Java 1.4. Is this something that has changed ? Or am I missing something ludicrously simple here
Thanks.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11249
    
  16

Originally posted by Spider Man:
The Mughal Java cert book I'm currently studying states that
"An instance initializer cannot make forward rererences to member varibles declared after the initializer"

I'm not sure, haven't tried it, but too me this looks like it's saying you can't to this

but again, i haven't tried it - not in a place where i have a sandbox to play in.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Forward references...