Start of Tutorial > Start of Trail |
Search
Feedback Form |
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.
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.
Creating Classes
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
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
Static nested classes, inner classes, anonymous inner classes, and local classes are covered.Enumerated Types
How to define, and use, an enumerated type a fixed set of constants.Annotations
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
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 by Gilad Bracha.
Start of Tutorial > Start of Trail |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.