Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we define a inner class in an interface?

 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we define a inner class in an interface?


-Minhaj
 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try it yourself??
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as i know, inner class could be declare in an interface..

this is the code for instantiate and access method :
 
Rajiv Chopra
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes we can declare inner classes in Interfaces too.

best practice is to seprate the implementations from Interfaces.
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Rajiv Chopra
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic