Can we have more that 1 class in 1 .java file ?
Can we have more that 1 class in 1 .java file ? If possible what will be the name of .java file?
Yes, you can have multiple classes within the same file. However, when done, the additional class(es) cannot be public. Only one class per java file may be public and the file name would reflect this class.
Thank you so much
if there is class in class ('inner class'), also this class can be public. in SoloLearn you can have all public class in one file, its not correct in java but it is Sololearn trick, where classes are automatic separated to files after send (after 'run' is pressed).