aspose file tools*
The moose likes Beginning Java and the fly likes An inner class in an Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "An inner class in an Interface" Watch "An inner class in an Interface" New topic
Author

An inner class in an Interface

Abhinav satyam Gupta
Greenhorn

Joined: Aug 15, 2008
Posts: 2
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

Joined: Oct 27, 2005
Posts: 19543
    
  16

Like fields, all inner classes inside interfaces are automatically public and static.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An inner class in an Interface
 
Similar Threads
Can I write static methods in an Interface?
Inner static class as test harness
theortical questions
Inner class concept
Static nested Interface