Is not an enclosing class Java
ZShape
is not static so it requires an instance of the outer class.
The simplest solution is to make ZShape and any nested class static
if you can.
I would also make any fields final
or static final
that you can as well.
As stated in the docs:
OuterClass.InnerClass innerObject = outerObject.new InnerClass();
Suppose RetailerProfileModel is your Main class and RetailerPaymentModel is an inner class within it. You can create an object of the Inner class outside the class as follows:
RetailerProfileModel.RetailerPaymentModel paymentModel
= new RetailerProfileModel().new RetailerPaymentModel();
What I would suggest is not converting the non-static class to a static class because in that case, your inner class can't access the non-static members of outer class.
Example :
class Outer
{
class Inner
{
//...
}
}
So, in such case, you can do something like:
Outer o = new Outer();
Outer.Inner obj = o.new Inner();