We need inner classes for:
1) An object of an inner class can access the implementation of the object
that created it- INCLUDING private data.
2) Inner classes can be hidden for other classes in the same package.
3) Anonymous inner classes are very useful when you want to define callbacks
on the fly.
liupu - 31 Jul 2006 13:44 GMT
> We need inner classes for:
>
[quoted text clipped - 3 lines]
> 3) Anonymous inner classes are very useful when you want to define callbacks
> on the fly.
Thanks. I agree. But I think it did more than it looks.
> /* It's wrong to write as follows: */
> public class C extends A,B {
> }
Yes, because the designers of Java, in their wisdom, decided to
prohibit multiple inheritance.

Signature
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
AndrewMcDonagh - 31 Jul 2006 23:07 GMT
>> /* It's wrong to write as follows: */
>> public class C extends A,B {
>> }
>
> Yes, because the designers of Java, in their wisdom, decided to
> prohibit multiple inheritance.
prohibit Multiple Implementation Inheritance, choosing Multiple
Interface Inheritance instead.
Jeffrey Schwab - 31 Jul 2006 23:25 GMT
>>> /* It's wrong to write as follows: */
>>> public class C extends A,B {
[quoted text clipped - 5 lines]
> prohibit Multiple Implementation Inheritance, choosing Multiple
> Interface Inheritance instead.
-1
Of all the features I miss in Java, multiple inheritance is probably
number two, right after template specialization. Number three is typedef.
liupu - 01 Aug 2006 04:15 GMT
> > /* It's wrong to write as follows: */
> > public class C extends A,B {
[quoted text clipped - 6 lines]
> C. Benson Manica | I *should* know what I'm talking about - if I
> cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
yes. The java designers prohibit multiple inheritance.
But in the case of "must multiple inheritance", I think the java
designers designs the Inner Class to do the same thing. And the Inner
Class did.
Right?
Oliver Wong - 02 Aug 2006 19:38 GMT
> yes. The java designers prohibit multiple inheritance.
> But in the case of "must multiple inheritance", I think the java
> designers designs the Inner Class to do the same thing. And the Inner
> Class did.
> Right?
I don't really understand your question, but I think the design decision
of allowing inner class doesn't have much to do with multiple inheritance.
- Oliver
Mike Schilling - 10 Aug 2006 07:38 GMT
>> yes. The java designers prohibit multiple inheritance.
>> But in the case of "must multiple inheritance", I think the java
[quoted text clipped - 5 lines]
> decision of allowing inner class doesn't have much to do with multiple
> inheritance.
IMHO, after Microsoft added the moral equivalent of method pointers to J++
and was soundly reprimanded by Sun for doing so, Sun was logically unable to
add method pointers itself, badly though they're needed for callbacks. Thus
inner classes were born.
See http://java.sun.com/docs/white/delegates.html for Sun's official take on
this, and decide for yourself how much is rationalization.
liupu - 14 Aug 2006 04:11 GMT
Thank you. I see.
> >> yes. The java designers prohibit multiple inheritance.
> >> But in the case of "must multiple inheritance", I think the java
[quoted text clipped - 13 lines]
> See http://java.sun.com/docs/white/delegates.html for Sun's official take on
> this, and decide for yourself how much is rationalization.