Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Inner classes" Watch "Inner classes" New topic
Author

Inner classes

Sricharan Modali
Greenhorn

Joined: Mar 30, 2004
Posts: 19
If an inner class is like a instance method(it can have modifiers like abstract, private etc) of the enclosing class then - why when an inner class is declared abstract the enclosing class need not be declared abstract?
for example
class Outer
{
abstract class Innner
{
}
}
complies fine!?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
An inner class is like a member method in the fact that it can have access modifiers, but it is still very different from a method.
If you declare a member method to be abstract, you are saying that the method can not be invoked by an instance of this class. Rather, you need some other class to override that method. Therefore, you have defined an "incomplete" class - one that can not be fully implemented. As such, you are required to mark the class as abstract.
However, if you have an abstract class within an enclosing class, there is no problem with the enclosing class. All of its member methods can be invoked properly, etc.
I suggest you check out the JLS, §8.1.2 Inner Classes and Enclosing Instances and Getting in Touch with your Inner Class in order to get a better understanding of some of the details pertaining to inner classes.
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Inner classes
 
Similar Threads
abstract inner class??
Can we access enum with object of d class?
local inner classes
abstact private
INNER CLASSES