February 27, 2013

Creating object to inner class in Java

I have a class definition like below and I want to create an object for the inner class.

class outerclass
{
    public class innerclass{
    }
}


To create an object for the above innerclass, we should follow the below syntax.

outerclass.innerclass obj=new outerclass().new innerclass();

No comments:

Post a Comment