• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An inner class in an Interface

 
Abhinav satyam Gupta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone..
I also have one query on the same...
An inner class in an Interface...
here is a sample..
interface Test
{
class Inner_test
{}
}

class test_class implements Test
{
public static void main(String []arg)
{
Inner_test in_t = new Inner_test();
}
}

This works fine... but my query is how can it work??
we are making an object of non-static class in static context.
which should return compilation errror....

May be i am overconcerned because of which i have overlooked an imp concepts....
But what i think it can work only when Inner_test is implicitly static in the interface. but IS IT???

waiting for reply...
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like fields, all inner classes inside interfaces are automatically public and static.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic