• 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

Method-Local Inner Class in static context - creation without enclosing class?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome,

Appearently there is no possibility to create an object od non-static inner class without its enclosing class instance, but try this:



Intresting thing - it works. What is more, this is not implicit nested class, it can't have any static fields or methods. WTF?

Regards
Arkadiusz Przechodzki
 
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A method-local inner class is defined within a method of the enclosing class. For the inner class to be used, ofcourse, you must instantiate it and such instantiation must happen within the same method but after the class definition code. A method-local inner class can also be declared in a static method, but then it can acess only static things.
 
reply
    Bookmark Topic Watch Topic
  • New Topic