Why does java file name must be same as public class name? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does java file name must be same as public class name?

7th Jul 2019, 1:14 PM
Programmer Raja
Programmer Raja - avatar
1 Answer
+ 2
Programmer Raja Generally the file name is keep same so that when one or more Java classes are made in one file then after compilation so many. Java files are generated and by this reason it's so hard to find the entry point and the main function for compiler so same name is kept so it directly have access to that entry point https://netjs.blogspot.com/2015/04/why-file-name-and-class-name-same-in-java.html?m=1 https://www.quora.com/Why-does-java-file-name-must-be-same-as-public-class-name
7th Jul 2019, 1:26 PM
MsJ
MsJ - avatar