O'Reilly logo

Java™ How To Program (Early Objects), Tenth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Section 3.4 Account Class: Initializing Objects with Constructors

• Each class you declare can optionally provide a constructor with parameters that can be used to initialize an object of a class when the object is created.

• Java requires a constructor call for every object that’s created.

• Constructors can specify parameters but not return types.

• If a class does not define constructors, the compiler provides a default constructor (p. 83) with no parameters, and the class’s instance variables are initialized to their default values.

• If you declare a constructor for a class, the compiler will not create a default constructor for that class.

• The UML models constructors in the third compartment of a class diagram. To distinguish a constructor ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required