Main.java:4: error:

Main.java:4: error: class PieceOf is public, should be declared in a file named PieceOf.java
public class PieceOf
^
1 error

compile time error…!! what to do?

To submit a program in Java for codechef online judge, you 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
     }
}

So in your case you should submit as,

class PieceOf
{
    // your code
}

or

public class Main
{
    // your code
}

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.