You are not logged in. Please login at to post your questions!


[closed] 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?

asked 09 May '12, 01:00

abhijeetiitkgp's gravatar image

accept rate: 0%

closed 26 Jan '17, 22:12

kcahdog's gravatar image


The question has been closed for the following reason "The question is answered, right answer was accepted" by kcahdog 26 Jan '17, 22:12

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


answered 26 Jan '17, 21:42

mb1994's gravatar image

accept rate: 0%

On CodeChef your class cannot be public, use default:

class life {

answered 09 May '12, 08:24

betlista's gravatar image

3★betlista ♦♦
accept rate: 11%

Answer is hidden as author is suspended. Click here to view.

answered 21 Feb '16, 17:47

poptu67's gravatar image

accept rate: 0%

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 :)

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 :)


answered 24 Jan '17, 15:53

akashbhalotia's gravatar image

accept rate: 10%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 09 May '12, 01:00

question was seen: 1,236 times

last updated: 12 Jul '17, 11:16