What should be the file name of a java program?

Inspite of writing the name of the file as the name of public class I am getting compilation error . Please help me.

For Java in codechef online judge have two options

You can submit a java program with class name as given below :

  1. public class Main{

public static void main (String[] args) throws java.lang.Exception {

// your code here
     }
}

  1. class YourClassName{

public static void main (String[] args) throws java.lang.Exception {

// your code here
     }
}

Remember " the name of a public class has to be "Main "

If you use some other class do not declare it public. Also do not use any packages.

For more information check codechef sample for java here.
Hope this helps.