+ 2

Why same file name of java program as class name.?

this is not compulsory in my view. but in questions , it's answer is true. please explain.

27th Mar 2017, 1:25 PM
Kuldeep Randhawa
Kuldeep Randhawa - avatar
3 Réponses
+ 11
To know which class contains main().
27th Mar 2017, 1:34 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
but we can compile the program with other name also. there is no problem. But while running the program we need to run with the class name which has java.
27th Mar 2017, 1:36 PM
Kuldeep Randhawa
Kuldeep Randhawa - avatar
+ 2
It is important when you use imports and packages as they don't refer directly to the class name but the file-structure
28th Mar 2017, 12:07 AM
Logan New
Logan New - avatar