站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Java Tutorial 5.0 英文版

Creating Classes - Java Tutorial 5.0 英文版

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

Trail: Learning the Java Language
Lesson: Classes and Inheritance

Creating Classes

This section shows you the main components of a class by using a small example that implements a stack — a data structure whose items are added and removed in a last-in-first-out (LIFO) fashion. The following figure shows the Stack class and identifies the elements of a class.

The Stack Class

The Stack Class


Note: java.util.List and java.util.ArrayList are generic types and require a type argument when used. The type argument is given in angle brackets (<Object>). For more information on generic types, see Generics (in the Learning the Java Language trail).
A class declaration first names the class, then specifies its superclasses and any interfaces it implements, followed by the class body. The next section, Declaring Classes (in the Learning the Java Language trail) covers the elements of a class declaration.

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

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