I am not able to understand why this code doesn\'t compile:
class A {
public static void main(String[] args) {
System.out.println(\"hi\");
}
}
p
Make the B nested of A, like this:
class A {
public static void main(String[] args) {
System.out.println("hi");
}
private class B {
int a;
}
}
Or move B to a separate file. Also you can stick with default access level, this way the class can be accessed only from within the package:
class A {
public static void main(String[] args) {
System.out.println("hi");
}
}
class B {
int a;
}