Main Page

Previous Next

Chapter 5: Defining Classes

Overview

In this chapter we will explore the heart of the Java language - classes. Classes specify the objects you use in object-oriented programming. These form the basic building blocks of any Java program, as we saw in Chapter 1. Every program in Java involves classes, since the code for a program can only appear within a class definition.

We will now explore the details of how a class definition is put together, how to create your own classes and how to use classes to solve your own computing problems. And in the next chapter we'll extend this to look at how object-oriented programming helps us work with related classes.

By the end of this chapter you will have learned:

  • What a class is, and how you define one.

  • How to implement class constructors.

  • How to define class methods.

  • What method overloading is.

  • What a recursive method is and how it works.

  • How to create objects of a class.

  • What packages are and how you can create and use them.

  • What access attributes are and how you should use them in your class definitions.

  • When you should add the finalize() method to a class.

  • What native methods are.

Previous Next
JavaScript Editor Java Tutorials Free JavaScript Editor