• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Forward references...

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
reply
    Bookmark Topic Watch Topic
  • New Topic