• 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

Static inner class question

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1 ) The RHE book states: You can use static inner classes as an extension to packaging. page 186, in Static inner classes.
what does this mean???
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static inner classes usually serve as helpers to their enclosing classes. This way of combining the main entity representation ie., your main class with the helper class provides a tighter coupling. This way of marrying related classes together and restricting their scope and existence is a better alternative packaging where you simply classify classes together under one package label.
Am I making sense here??
Ajith
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an small example to illustrate the verbose post by
Ajith
<pre>
public class StaticInnerEx {
StaticInnerEx() {
System.out.println( "C'tor StaticInnerEx ");
}
static class Inner{
Inner() {
System.out.println( "C'tor the static Inner ");
}
}
public static void main(String argv[]) {
StaticInnerEx out = new StaticInnerEx();
// The following expression gives the impression that Inner lives
// in pkg StaticInnerEx, dosen't it ?
StaticInnerEx.Inner in = new Inner();
}
}
</pre>

Originally posted by Ajith Kallambella:
Static inner classes usually serve as helpers to their enclosing classes. This way of combining the main entity representation ie., your main class with the helper class provides a tighter coupling. This way of marrying related classes together and restricting their scope and existence is a better alternative packaging where you simply classify classes together under one package label.
Am I making sense here??
Ajith


 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks bongadi. I think I need to mature from being just a theoretician.
Ajith
 
It's never done THAT before. Explain it to me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic