The moose likes OO, Patterns, UML and Refactoring and the fly likes Class inside interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Class inside interface" Watch "Class inside interface" New topic

Class inside interface

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 761

I came to know that we can declare class inside an interface...

So i was wondering what is the use of declaring class inside an interface ???

Basically interface defines the contact between the class implementing the interface..

Jigar Naik

Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
The only difference between a top level class and a class defined in an interface is the different namespace. It's used very seldomly, but if it's used at all, then typically to communicate that the class is very tightly coupled to the interface.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
It's not supposed to be used. It's like appendix of human, I believe.

If I've time, I'll come up with more technical answer.

SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
I agree. Here's the link:
subject: Class inside interface
jQuery in Action, 3rd edition