aspose 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 9280
    
  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: 253

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?
 
Similar Threads
Inner Classes in Interfaces?
inner class
anonymous inner class that extends a super and implements an interface
anonymous inner class question
Reason to create inner class in an interface