You have to create first an instance of mProgram before creating an instance of an inner class, or you can declare the inner class (NrlData in that case) as static, but you still need the mProgram class to access it (but you don't have to instantiate it.
public class mProgram {
public class NrlData {
...
}
public static void main(String[] args) {
mProgram.NrlData nrlData = new mProgram().new NrlData();
}
public void aMethod() { // accessing inner class from the "this" instance
NrlData nrlData = new NrlData();
}
Or
public class mProgram {
public static class NrlData {
...
}
public static void main(String[] args) {
mProgram.NrlData nrlData = new mProgram.NrlData();
}
}
Just take the first case, where NrlData is not static.
From within a non-static function inside mProgram class, you don't need to create a mProgram instance, because it uses the this
instance.
Now if you try to access the inner class from another class, as you don't have any instance of mProgram, you'll have to create first that instance. It's the reason why you have the problem only in NrlMain and not in mProgram.
public class NrlMain {
public void accessingInnerClass() {
// Creating the mProgram instance
mProgram mprogram = new mProgram();
// Creating inner class instance
mProgram.NrlData nrlData = mprogram.new NrlData();
}
}