How can I resolve "an enclosing instance that contains X.Y is required"?
Declare Y as static to avoid creating instance of X.
public class X
{
public static class Y {
}
}
First of all you have to create an object of X class (outer class) and then use objX.new InnerClass()
syntax to create an object of Y class.
Try,
X x=new X();
X.Y y=x.new Y();
You want to declare static inner classes: public static class Y
.