Chapter 5. OOP Part II—Constructors and Visibility

  • Creating New Objects: Constructors

  • More About Methods

  • Variable-Arity Methods

  • Packages

  • How the JDK Finds Classes

  • Access Modifiers

  • Exercises

  • Some Light Relief—It's Not Your Father's IBM

All the way back in Chapter 2, we briefly mentioned two concepts that are used a lot with classes: constructors (to create new objects), and access control (to deliberately restrict or increase the visibility of classes and things in classes). This chapter is where we deliver the full details on these two topics. Constructors are usually described as being like methods “with a few differences” and method is the object-oriented name for a function or procedure. So there's a section on methods and ...

Get Just Java™ 2 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.