added basic information about default constructors in the index file for methods (#29797)

This commit is contained in:
howieandersen
2019-03-15 08:03:22 +01:00
committed by The Coding Aviator
parent 9a5e3c5e0e
commit da84162282

View File

@ -106,3 +106,5 @@ public class Car {
```
The `Car` class and the `Car(String model, int numberOfWheels)` method have to have the same name in order for java to know that it is the constructor. Now anytime you instantiate a new `Car` instance with the `new` keyword you will need to call this constructor and pass in the needed data.
When we don't specifically define a constructor for a class, java creates a default constructor. This is a non-parameterized constructor, so it does not contain or accept any arguments. The default constructor calls the super class constructor and initializes all necessary instance variables