public class name and file name are same in Java  | Java Free Tutorials

This Java Free Tutorials “public class name and file name are same in Java” is providing information about public class rules in java application and why we need to save public class with the same name.


 

public java class rules:

  • If the class is public, class name and file name should be same.

public class in java

 

  • We cannot define 2 ‘public’ modifier classes in a single java source file.

 

The following program shows clearly, public class name save with same name:

Share this