• 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

Inner Classes

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am studying myself silly with inner classes, and the more I study them, the more confused I become. For instance, I wrote the following piece of code which compiles and runs fine, but I can't understand why it is showing the integer "j" to be 0 (zero) instead of 5 (five). I would think (1) the compiler would croak, (2) I'd get a runtime error, or (3) the value would be 5 ...

My results ...
x.z.j = 0 // ???
x.z.k = 0
x.z.getj() returned: 0 // ???
x.z.geta() returned: 5
[I added UBB CODE tags to your source code to make it more readable. Please try to use them in the future. Learn more about UBB codes - Ajith]
[This message has been edited by Ajith Kallambella (edited September 15, 2000).]
 
Stephen Pride
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I had JDK 1.1.7 when I ran this test. When I put on JDK 1.3, it ran as I thought it might ...
x.z.j = 5
x.z.k = 0
x.z.getj() returned: 5
x.z.geta() returned: 5
 
reply
    Bookmark Topic Watch Topic
  • New Topic