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.
More Related Contents:
- How to call the getters and setters of inner class attributes in the TestApplication.java class?
- Java inner class and static nested class
- What causes error “No enclosing instance of type Foo is accessible” and how do I fix it?
- Difference between final and effectively final
- Why can outer Java classes access inner class private members?
- Why does Java prohibit static fields in inner classes?
- When exactly is it leak safe to use (anonymous) inner classes?
- Java: Static vs inner class [duplicate]
- Getting hold of the outer class object from the inner class object
- Why Java inner classes require “final” outer instance variables? [duplicate]
- How can I include raw JSON in an object using Jackson?
- Why can’t we have static method in a (non-static) inner class (pre-Java 16)?
- How to instantiate non static inner class within a static method?
- Instantiating inner class
- Can we create an instance of an interface in Java? [duplicate]
- Why is an anonymous inner class containing nothing generated from this code?
- Is it possible to make anonymous inner classes in Java static?
- “Non-static variable this cannot be referenced from a static context” when creating an object
- Is it possible to create an instance of inner class using Java Reflection?
- How can “this” of the outer class be accessed from an inner class?
- Instantiate private inner class with java reflection
- Java: Non-static nested classes and instance.super()
- Inner class and local variables
- Java (anonymous or not) inner classes: is it good to use them?
- What are the purposes of inner classes
- Accessing outer class variable in inner class
- Usage of inner class
- In Java nested classes, can the enclosing class access private members of inner classes?
- Java: calling outer class method in anonymous inner class
- Accessing outer class members from within an inner class extending the outer class itself