Additional check for Java class definition

It would be great when Java solution is submitted to do simple grep before compiling it, if there is

public class

definition in the code. If so, return error message that class cannot be public. Public classes are valid in language, but if I submit such solution I’m getting compilation error.

For example there is such check on (but class here has to be public contrarily). Almost in every contest I have at least one such submission :frowning:

Make sure that you are naming the file same as the name of the class declared as public.
In Java, it is compulsory to name the file as same as the name of public class.

The problem is, that your class on CodeChef cannot be public…