Why can't a static method create inner class objects
In the main method of a program. I tried to initialize an inner class but it didn't work. Why does this happen?
So this doesn't compiles:
Code:
public class ExampleError {
public static void main (String[] args) {
InnerClass innerClass = new InnerClass();
}
class InnerClass {
}
}
But the following does:
Code:
public class ExampleError {
public static void main (String[] args) {
InnerClass innerClass = new InnerClass();
}
}
class InnerClass {
}
Any help please?