New course! Every coder should learn Generative AI!
Try a free lesson0
Constructors in java are used to initialize an object and there is no other way to intialize an object. If you don't write a constructor, java will write one for you:
[name of class]() {}
This is the default constructor. If the name of the class is "Example", java will write:
Example() {}