Static methods for cats

  • 2
  • Locked
The secret CodeGym center has entered into an agreement with cat breeders to supply them with applications. In particular, as beginning programmers study getters and setters, they write a cat-counting program for cat lovers. Your time has come: Create a Cat class with static methods that you will use to get or change the number of cats.
You can't complete this task, because you're not signed in.
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Mitesh Shah
Level 11 , London, United Kingdom
30 December 2019, 10:54
Why does the setCatCount methoud require the variable to be set using Cat.catCount while the getCatCount method can return the value by calling the catCount variable without the Cat. in front of it?
andy 6473
Level 9 , Bangalore, India
19 June 2020, 04:19
If we write public static void setCatCount(int catCount) { //write your code here catCount = catCount; } then catCount becomes the local variable of the method setCatCount. That is the reason we use Cat.catCount , to access the static variable . since method cannot access the static method directly;