File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can we define a inner class in an interface? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can we define a inner class in an interface? " Watch "Can we define a inner class in an interface? " New topic
Author

Can we define a inner class in an interface?

Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

Can we define a inner class in an interface?


-Minhaj


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

Why don't you try it yourself??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

As far as i know, inner class could be declare in an interface..

this is the code for instantiate and access method :


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Rajiv Chopra
Ranch Hand

Joined: Dec 19, 2008
Posts: 62
Yes we can declare inner classes in Interfaces too.

best practice is to seprate the implementations from Interfaces.


Rajeev Kumar
SCJP 6.0 Certified 96%
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 255

Hi All,

I think,Minhaj's question was about defining not declaring.

Minhaj - we can define and declare the inner class in an interface. As you can see the below mentioned section of code.



Regards
Salil Verma
Rajiv Chopra
Ranch Hand

Joined: Dec 19, 2008
Posts: 62
Salil Vverma wrote:Hi All,

I think,Minhaj's question was about defining not declaring.

Minhaj - we can define and declare the inner class in an interface. As you can see the below mentioned section of code.



Hi Salil,
Thanks for example.
Please can you explain the meaning of define and declare seprately.
How we can define? and How we can declare?
Thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we define a inner class in an interface?