I have a doubt in using Inner Classes in java. Here is my code.
Code:
public class Test{
public class InnerClass{
public static int num = 10;
}
}
It's not allowed. I got the error message "The field num cannot be declared static; static fields can only be declared in static or top level types".
public class Test{
public class InnerClass{
public static final int num = 10;
}
}
But It's allowed. I have not declared InnerClass
as static and top level element but how it works?