The Java Course provides a general introduction to programming in Java. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
Home Queues and Priority Queues Abstract Class | ||
See also: Defining an Abstract Class | ||
Search the VIAS Library | Index | ||
Abstract Class
An abstract class is a set of classes. The abstract class definition specifies the requirements a class must satisfy to be a member. Often abstract classes have names that end in "able" to indicate the fundamental capability the abstract class requires. For example, any class that provides a method named draw can be a member of the abstract class named Drawable. Any class that contains a method named start can be a member of the abstract class Runnable. As of Java 2, Java provides a built-in abstract class that we can use in an implementation of a Priority Queue. It is called Comparable, and it means what it says. Any class that belongs to the Comparable abstract class has to provide a method named compareTo that compares two objects and returns a value indicating whether one is larger or smaller than the other, or whether they are the same. Many of the built-in Java classes are members of the Comparable abstract class, including numeric wrapper classes like Integer and Double. In the next section I will show how to write an ADT that manipulates an abstract class. Then we will see how to write a new (concrete) class that belongs to an existing abstract class. Then we will see how to write a new abstract class.
|
||
Home Queues and Priority Queues Abstract Class |