I am not a Java expert that reason could be for having the main public but for having the class public the reason could be it can be invoked from any package.