We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In Java every file should have at most one public class, and the public class name has to match with the name of the file. E.g:
publicclassX{}// the file should be named X.java
The file X.java can define multiple classes, but only X class can be public as a "top level class". Having said that. The compiler allows inner classes to be public, E.g:
// file name should be TopLevel.javapublicclassTopLevel{publicstaticclassNotTopLevel{}publicclassAnotherNotTopLevel{}privateclassX{}}classTopLevelDifferent{// can't be public}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sorting: Comparator
You are viewing a single comment's thread. Return to all comments →
In Java every file should have at most one public class, and the public class name has to match with the name of the file. E.g:
The file X.java can define multiple classes, but only X class can be public as a "top level class". Having said that. The compiler allows inner classes to be public, E.g: