Use a static variable to count instances of a class
Create a class named Student
with a static variable count
of type int
. Initialize it to 0. Then, create a constructor for the class that increases the value of count
by 1 every time a new instance of the class is created. Finally, create a static method named getCount
that returns the current value of count
.
Instructor solution
You may exit out of this review and return later without penalty.