File name: B.java
public class B
{
public static void main(String[] args){}
}
public class A{}
java B.javaruns without errorjavac B.javagives a compile error:class A needs to be declared in a file A.java
I understand that a java file can not have more than one public class, but why can a java file run without error using the java command when you get compile errors for the code using javac?