Why can I not use this. catCount on the setter method?
Daniel Whyte
Level 17
Cat.catCount
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
remote87
25 January 2021, 10:20
catCount is a static variable - it's variable of the class, not the object. You use "this" to call the object aka:
set catCount on THIS specific cat object. When the variable is static as in here, it is referring to the Cat class, that's why "this" has no place here. Hope you understood me :)
+4