Java Reference
In-Depth Information
Adding a Constructor to the Vehicle Class
We can improve the
Vehicle
class by adding a constructor that automatically initializes the
passengers
,
fuelcap
, and
mpg
fields when an object is constructed. Pay special attention
to how
Vehicle
objects are created.