The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Trail: Learning the Java Language

Lesson: Classes and Inheritance


This chapter has been updated to reflect features and conventions of the latest release, JDK 5.0, but it is not yet final. We've published this preliminary version so you can get the most current information now, and so you can tell us (please!) about errors, omissions, or improvements we can make to this tutorial.
With the knowledge you now have of the basics of the Java programming language and creating and using objects, you can learn to write your own classes. In this chapter, you will find information about defining your own classes, including declaring member variables, writing methods, inheriting variables and methods from superclasses, nesting classes within other classes, and so on.

Creating Classes (in the Learning the Java Language trail)

This section shows you the anatomy of a class, how to declare variables, define methods, write constructors, control access to class members, use annotations and more.

Managing Inheritance (in the Learning the Java Language trail)

This section covers issues relating to class hierarchies: how to override methods, hide methods or member variables, how to use super, the use of final to prevent subclassing, the use of abstract methods and classes.

Nested Classes (in the Learning the Java Language trail)

Static nested classes, inner classes, anonymous inner classes, and local classes are covered.

Enumerated Types (in the Learning the Java Language trail)

How to define, and use, an enumerated type — a fixed set of constants.

Annotations (in the Learning the Java Language trail)

Annotations allow you to add information to your program that is not actually part of the program. This section describes three built-in annotations that you should know.

Generics (in the Learning the Java Language trail)

Even if you don't plan to write a generic type or a generic method, you will very likely encounter generics when you use Java SE API. This section tells you how to understand, and use, the syntax of generics. For information on how to write a generic type or method, see Generics (in the Learning the Java Language trail) by Gilad Bracha.

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.