File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can a class be declared inside a interface?

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this question from here


What is the usage of this kind of declaration?
 
Lokesh Duseja
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can!!

You can even implement this interface and make an object of this "inner static" class... see the code below




My friend.... you were too kind to declare that inner class "public static" and the interface as "abstract"... these are implicit!!

I think my explanation is correct..... if not, blame it to the beer..... normally i don't "drink and drive"!!
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot...BTW, Can we 'override' that class declaration in our implementation class?
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no you can't because ... it is implicitly final and static
 
Lokesh Duseja
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did not get the last question..... overriding a class? i only heard of overriding method....
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lalit Mehra wrote:no you can't because ... it is implicitly final and static


OMG! I forgot it thanks.....
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lokesh Duseja wrote: i did not get the last question..... overriding a class? i only heard of overriding method....

+1, there is nothing like overriding a class
Classes declared inside of interfaces are not final
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:
Lokesh Duseja wrote: i did not get the last question..... overriding a class? i only heard of overriding method....

+1, there is nothing like overriding a class
Classes declared inside of interfaces are not final


I hope no one ever does that in production
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:I hope no one ever does that in production

Why not, the programmer can win an Obfuscated Code Contest with it
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic