Answers for "java get number of class instances"

0

java get number of class instances

public class Bicycle {
...
    public static int instances = 0;

    {
        ++instances; //separate counting from constructor
    }
...
    public Bicycle(int gear, int speed, int seatHeight, String color) {
        gear = 0;
        speed = 0;
        seatHeight = 0;
        color ="Unknown";
    }
}
Posted by: Guest on October-15-2020

Code answers related to "java get number of class instances"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language