Compilation error

public class life
public static void main(String[] args)throws IOException
InputStreamReader read = new InputStreamReader(;
BufferedReader in = new BufferedReader(read);
System.out.println(“Enter no.”);
int a= Integer.parseInt(in.readLine());

this code runs in my BLUEJ environment which i use for java, but at code chef its giving a compilation error.
what to do?

On CodeChef your class cannot be public, use default:

class life {

good the receiver after inputting the page Therefore the telephone will need to possess nice.

I see your code pal. It is the “Life, Universe and Everything” problem. The reason it is not compiling, is because in Codechef and other Online Programming Platforms, you cannot declare your class public. It is against their rules. So, if you just change it to class life{}, it won’t show a compilation error :slight_smile:

Moreover, another error which I found in your code is printing “Enter a number”.
I know that in schools and colleges, we are taught to give the prompt “Enter a number”, “Enter the size”, etc to start the BlueJ terminal window. But this is a very wrong practice when it comes to Competitive Programming. You will simply get a WA (wrong answer).

Instead of that, what you can do is print a blank line (Sopln()) just once, in the beginning, when working with BlueJ and thereby, also avoid WA. Understand that this practice of printing a line to start the Terminal Window is only required for Bluej, while almost all other Online & Ofline IDEs don’t require this.

If you found this helpful, please mark it as accepted :slight_smile:

Your class is not public. Please read the codechef submission guidelines here:

1 Like