0

Starting a Java File in SoloLearn

I know in SOLOLEARN they have java starting with class than the variable name. For example, class Solo However in most java I have seen the first line of text (except for import) for class starts as public class name For example, Public class Solo this would be declaring the class solo before the main method is invoked. Why is it on Solo learn it's backwards and missing the public or private?

24th Oct 2017, 12:18 AM
Abris
Abris - avatar
2 Réponses
+ 3
There is no difference. The public is optional and not required. If the public is there, the class can be reference from everywhere. If it is missing, the class can only be referenced by other classes in the same package. SoloLearn doesn't support packages as you can only have one source file so all code is in the same package. Therefore, dropping or adding it here doesn't have any effect.
24th Oct 2017, 4:01 AM
John Wells
John Wells - avatar
0
Thank you, now it makes sense.
27th Oct 2017, 11:00 PM
Abris
Abris - avatar