File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why we can write Class inside interface ? What's it use ?

 
sandip sangale
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
elester johnson
Greenhorn
Posts: 3
Eclipse IDE Linux Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep! what exactly do you want to do regarding interfaces and classes. I'm going to assume you are doing this just to try everything possible with interfaces and classes, as long as you get their concepts and uses correct in the first place.
Coming back to your question - yes you can compile the program, but you can't run it as there is no main method in there. If you try a java blah, then the jvm gives a no main method error because it cant get a direct handle to the class as it is in the interface and as you may know you can't run an interface even though the main method is inside the class.
hope this helps.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
9.5 Member type declarations.

I don't think I've seen this used anywhere.

By the way, you can execute the inner class via the interface :


>java -cp . InterfaceWithClass$InInterface
Hello
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic