Join us, let's discuss Web3, crypto and blockchain technology.

Calling Another Constructor

Some constructors you write may be a superset of another constructor defined in your class; that is, they might have the same behavior plus a little bit more. Rather than duplicating identical behavior in multiple constructor methods in your class, it makes sense to be able to just call that first constructor from inside the body of the second constructor. Java provides a special syntax for doing this. To call a constructor defined on the current class, use this form



dp

Read next...

Mountains
Hivefirm
Hivefirm is a future focused community for all things Web 3 and crypto-related content

Follow us

Discover more of what matters to you