• 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

How to access an Inner Class' method

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

Is there a way to access an Inner Class' method which is not an overridden version of the superclass' method.
as in

class PopCorn{
public void Pop(){ }
}

class F
PopCorn p = new PopCorn(){
public void pop() {}
public void f1(){} // how can we access this
}
}

And is it possible to have an anonymous class without it being asscoiated with a superclass ?

Regards ,
Akash
 
Marshal
Posts: 28260
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually neither of those questions are limited to inner classes. If you try your PopCorn example as a top-level class which extends PopCorn, the same question arises. (And it has the same answer.)

Likewise you can't declare any class -- anonymous or otherwise -- which isn't a subclass of another class. If nothing else, a class you declare is a subclass of Object.
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no you can't access any method added in annonymous inner class which is not present in it's super class.
 
akaash singh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Likewise you can't declare any class -- anonymous or otherwise -- which isn't a subclass of another class. If nothing else, a class you declare is a subclass of Object.

Paul Clapham . Ok , apart from the Object .
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic