// Result is 0, but the system reads it as passed, weird
package com.codegym.task.task04.task0404;
/*
Cat register
*/
public class Cat {
private static int catCount = 0;
public static void addNewCat() {
//write your code here
Cat cat = new Cat();
Cat.catCount = Cat.catCount+1;
}
public static void main(String[] args) {
System.out.println(Cat.catCount);
}
}
Sth is wrong
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Switch/Cypher
9 November 2020, 10:59
The result is 0 because you never run the addNewCat method, so the cat Count never gets increased.
If you ran this then the answer would be 1. +1
Albert
11 November 2020, 15:07
Thank you
I am so careless
Wish you good health and all the best in the UK
0