• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class in an interface  RSS feed

 
PradeepKumar Prashanth
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone help me with the explanation of having a class within an interface. When can this be used and also what in meant when we say static methods can be hidden. Please gimme a very good response.

Thanks and regards
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the interface question:
can you give me a very good example first ?
because i do not understand the question!

for the static/hide/method question: why don't you try to solve this problem by searching the web or javaranch first ?
http://www.google.com/search?q=java+static+hide
 
PradeepKumar Prashanth
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interface.java
public Interface Demo
{
class ClassWithinInterface
{
// All variables and methods
}
}
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A class within an interface becomes a static nested class in the class that implements the interface.



Note what happens if you try to change the main method to



The error you get is

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!