Chapter 8
Using Java Constructors
Constructors are the last major Java class elements you need to cover. They’re a lot like methods in appearance. In fact, I’ll be able to use some of the discussion in Chapter 7, “Using Java Methods to Communicate,” to address what the similarities are and how you can apply them.
Unlike methods, constructors tie into the way objects get made, not just for the class they belong to, but also for classes they inherit from and classes that inherit from them. That subject is a chapter in itself, so here we’ll confine discussion to the way constructors work for the class at hand.
In this chapter, we’ll cover the following topics:
- Using the default constructor
- Defining alternate constructors
- Adding parameters to constructors ...
Get Java SE 7 Programming Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.