Interfaces are always abstract, but they're not necessarily public. You may have heard that the members of an interface (the fields, methods, and nested classes (or interfaces) declared directly inside the interface) are always public. That's true.* But that's not the same as saying that the interface itself is public.
* Note I said, declared directly inside an interface. You could have a nested class inside an interface, and that class could declare a private field - but that field would not be directly inside the interface, and it would not be a member of the interface. In case you were wondering... [ February 22, 2005: Message edited by: Jim Yingst ]
Interesting. I thought I read in K & B's book that interfaces are always public (I'm pretty sure about that, at least in the portugues version of the book). So they can have default access too, unh. Thanks Jim.
That`s not exactly the point. As I said, i thought i had seen in Kathy`s book (and i actually comfirmed it in the portuguese version of the book) that interfaces are always public. So even if i didn`t insert the public keyword before interfaces it would be a public one, but this is not true.
hai i tried to put the interface inside a inner class but it give a compile error.
I am confused.
As Jim said an interface inside a class is abstract by default. But when i tried to put the interface inside a inner class i get a compile error saying that " static declaration inside an non-static inner class".
So according to this compile error,the interface inside an inner class is static by default.
So is it like this,only static inner class can have interface as its member....???
Hi Mike. Now I understand that, but I have the portuguese version of the book. I carefully took a look at it and it says: "Interfaces s�o sempre publicas e abstratas ..." Translating to english it means that interfaces are always public and abstract. This for sure a translation error from the original version, just like some other ones that I`ve seen. It`s said, but the portuguese version of the book has quite a large number of errors for this kind of book.