You have to have a reference to the other outer class as well.
Inner inner = new MyClass().new Inner();
If Inner was static then it would be
Inner inner = new MyClass.Inner();
More Related Contents:
- Java: Static vs inner class [duplicate]
- Why can’t we have static method in a (non-static) inner class (pre-Java 16)?
- Static class instance inside class
- What does the ‘static’ keyword do in a class?
- Change private static final field using Java reflection
- What is the difference between a static and a non-static initialization code block
- Difference between final and effectively final
- Difference between Static methods and Instance methods
- Getting the class name from a static method in Java
- Why can’t we use ‘this’ keyword in a static method
- Instantiating inner class
- Can we create an instance of an interface in Java? [duplicate]
- in what order are static blocks and static variables in a class executed? [duplicate]
- 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
- Why static fields are not initialized in time?
- Why are all fields in an interface implicitly static and final?
- Are static variables inherited
- What does `public static void main args` mean?
- Instantiate private inner class with java reflection
- Order of static variable initialization, Java [duplicate]
- Can we call a static method with a null object in Java? If so, how?
- Java: Non-static nested classes and instance.super()
- Why NoClassDefFoundError caused by static field initialization failure?
- 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
- Difference between Dynamic and Static type assignments in Java
- Accessing outer class members from within an inner class extending the outer class itself