×

Loading...

About interface and inner-class.

本文发表在 rolia.net 枫下论坛Let me try to explain in English.
I think you have read a lot about Java. Here I try to explain what you concerned in my way of understanding things. Hope not to make any confuse.

Interface is a definition about how a entity to communicate with other entities. It does not matter how the interface is immplemented.

For example of PCI slot in personal computer: it is a interface between the PCI cards and the mainboard. But different mainboards and different PCI cards have their own immplementations. If the immplementations conform the interface definition they will work well.

In Java the Interface is a declaration of a set of methods and some named constants in a class, their immplementations are not defined or specified. Just like a PCI slot in personal computer.
You can immplement an interface (call it PCISlot) as following:

class PCICard implements PCISlot {
......
}

or

class MainBoard implements PCISlot {
......
}

As far as I know, inner-class was introduced from Java JDK 1.1and later and just is a nonstatic class defined within another class

class OutClass {
class InnerClass {
......
}
}

Please pay some attentions to some access limitations on the inner class.

I am not sure if these make things clear. Hope not to make you confuse again.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Sign in and Reply Report