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.
Solution is not declared to be public.
I think I figured out why Checker class is not allowed to be public, A java file can have only one public class, the compilation unit is saved as .class file.
Example : class A{
public static void main(String[] args){
//any code
}
}
class B{
any method(){
}
}
Now, the compilation unit is saved as a class file names A.class, therefore class B cannot be public. A( the class containing main) may or may not 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 →
Solution is not declared to be public. I think I figured out why Checker class is not allowed to be public, A java file can have only one public class, the compilation unit is saved as .class file. Example : class A{ public static void main(String[] args){ //any code } }
class B{ any method(){
} }
Now, the compilation unit is saved as a class file names A.class, therefore class B cannot be public. A( the class containing main) may or may not be public.