Cat code won't compile

  • 5
  • Locked
The first postulate of the intergalactic railway states: if cats have a problem, abandon everything to help them solve it. Because having problems is contrary to the nature of cats. So we have a program that displays cat data after reading it from the keyboard. But something isn't right, and it won't compile. Fix the bug!
You can't complete this task, because you're not signed in.
Comments (21)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 12 , Corredor
17 August 2021, 17:23
hi everybody, why I can't assign conversion to integer before doing the the object? int age = Integer.parseInt(reader.readLine()); So I mean, for example new Cat(name, age....... ;)
Level 8 , Versailles, France
1 November 2021, 18:26
you can
Level 11 , Banja Luka, Bosnia and Herzegovina
4 March 2021, 20:14
Using Scanner is more effective. It can read int directly without converting them from string to int.
Level 15 , Providence, United States
25 June 2020, 03:31
make this change to line 15 and it should work if (name.isEmpty()|| name.equals(" ")) break;
Karas Java Developer
7 September 2020, 23:51
It worked, also make sure you add a space.
Roman Grygorczuk
Level 19 , Cracow, Poland
21 November 2020, 16:28
the position of if statement is very important
Level 15 , Old Town, United States
25 April 2021, 23:23
space is not necessary.
Level 15 , Old Town, United States
25 April 2021, 23:25
it passes without || name.equals("")
Peter Karanyi
Level 9 , Cowplain, United Kingdom
12 June 2020, 17:16
My code compiles in IntelliJ, then I copy paste it here, and won't compile... How is that possible???
Alex Vypirailenko Java Developer at Toshiba Global Comme
13 June 2020, 07:07
Please submit a question with your code in the Help section.
Nickolas Johnson
Level 8 , St. Louis, United States of America
30 March 2020, 19:51
Log was right, for some reason you have to put another line in the input box for it to work. Gotta say, I hated this one with a fiery passion. I need a fregin break after this one.
Level 14 , Nottingham , United Kingdom
12 March 2020, 14:17
After digging around the help files I discovered that my code originally didn't work because I needed to add a blank line at the end of the pre-written input data. Wasn't expecting to have to mess around with the Input box
25 February 2020, 08:26
They need to fix this one... i was able to pass with a nullpointerexception.
Level 41
26 February 2020, 07:57
Please give me your code in direct message.
Bert Doe
Level 22 , Flanders, Belgium
9 April 2020, 08:39
I also passed this one with a null pointer exception
Level 16 , Birmingham, United Kingdom
15 November 2020, 20:24
...pass with a null pointer exception.....
Level 13 , Krakow, Poland
18 November 2020, 10:33
I also passed with the NullPointer
Level 15 , Colnbrook, United Kingdom
25 January 2020, 15:58
If you find the requirements a bit confusing, then all you have to do is FIX existing code and add what is needed so if you enter name(string), age(int), weight(int), tail (int) it creates an object with those characteristics (variables). If name is empty, program stops and prints existing data; if no data....then it prints nothing(in case first name is empty, program breaks and prints nothing).
Level 34 , Phnom Penh, Cambogia
3 June 2019, 06:39
Thanks...all ok
Level 34 , Phnom Penh, Cambogia
3 June 2019, 01:49
who know why isEmpty not work? Thanks
Level 41
3 June 2019, 06:24
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at