• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Traps to be aware of in any SCJP test !!!!! :)

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are static inner classes referred to sometimes as nested top-level classes? I think it is just silly semantics. Someone probably, realized once that the below two code fragments would have exactly the same implementation if you pretend that the latter is a legal name. I can see the reasoning now: "Since in the implementation of an inner static class, the binary code doesn't need a pointer to an instance of the outer class, maybe we shouldn't call an inner static class inner at all, but rather nested top-level."
Fortunately, wiser heads prevailed and they mostly abandoned the semantic quibble, rather than pushing a confusing, yet meaningless to non-language-implementers, distinction.
below:
class outer {
static class inner {
}}
class outer {}
static class outer.inner {}
 
Jeff L.
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops again.
Final local variables cannot be initialized once, so from the perspective of local variables, what I said was true.
Final member variables behave differently. You can't initialize them on first use, but what you can do is initialize them in each constructor, rather than initializing them inline. Therefore I misspoke when I said the initialization had to be during declaration.
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic