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 Trees Defining an Abstract Class | ||
See also: Abstract Class, Implementing an Abstract Class | ||
Search the VIAS Library | Index | ||
Defining an Abstract Class
An abstract class definition looks a lot like a concrete class definition, except that it only specifies the interface of each method and not an implementation. The definition of Visitable is public void visit (); } That's it! The word interface is Java's keyword for an abstract class. The definition of visit looks like any other method definition, except that it has no body. This definition specifies that any class that implements Visitable has to have a method named visit that takes no parameters and that returns void. Like other class definitions, abstract class definitions go in a file with the same name as the class (in this case Visitable.java).
|
||
Home Trees Defining an Abstract Class |