Can a public class MyClass be defined in a source file named YourClass.java?

Q

Can a public class MyClass be defined in a source file named YourClass.java?

✍: Guest

A

No the source file name, if it contains a public class, must be the same as the public class name itself with a .java extension.

2013-07-02, 2767👍, 0💬