• 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

instantiating an inner member class

 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not a question.
Various ways to instantiate a non-static member class.

[ August 13, 2003: Message edited by: Marlene Miller ]
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marlene this is a great posting, thank you. It covers everything required for inner class instantiation. Could you please add for static and anonymous also?
[ August 13, 2003: Message edited by: venu gopal ]
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Venu for reading my posting. Thank you for your response. That's a good suggestion. I will try to do something for those other classes, now that I know it might be helpful.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Various ways to instantiate a static member class.

[ August 13, 2003: Message edited by: Marlene Miller ]
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some anonymous class instantiations.

Note: A is not final
[ August 14, 2003: Message edited by: Marlene Miller ]
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A thought about instantiating anonymous subclasses of nested classes.
I think it is safe to say,
If C is a top-level, static member, non-static member or local class,
and C is not final, then where ever this is valid syntax to instantiate the class,
new C()
new Outer.C()
outerRef.new C()
new Outer().new C()
this is also valid syntax to instantiate an anonymous class.
new C() { <body of anon class> }
new Outer.C() { <body of anon class> }
outerRef.new C() { <body of anon class> }
new Outer().new C() { <body of anon class> }
[ August 14, 2003: Message edited by: Marlene Miller ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please add for static and anonymous also?
Why no local?
Looking good, Marlene. Thanks for posting these.
 
Grow your own food... or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic