I am working on a class with an inner class
My code:
package com.solignis;
public class Config {
public static final Target target;
class Target {
public void create(String targetName) {
System.out.println("Created" + targetName);
}
public void destroy(String targetName) {
System.out.println("Destroyed" + targetName);
}
}
}
IntelliJ doesn't see anything wrong with the subclass but it keeps complaining that I have not initalized the static variable target. But when I try to initialize it with something like null I get a null pointer exception (no surprise there!) but I don't what I could initialize the variable with since as far I can understand all its just an instance of the Target subclass in the Example superclass (is this right?). Also Target has no constructor so I cannot declare new on target in order to initialize the variable.
So what could I do?
Please correct me if I am incorrect about my understanding of this I am still trying to wrap my head around the more "deeper" workings of Java.