h3.Class Inheritance Code Samples
Learn about classes, member variables, methods, inheritance, nested classes, and more.
* Creating Classes
* Inheritance
h5.Creating Classes
* [AClass.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/AClass.java] declares an instance member variable, an instance method, a class variable, a class method, and main. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Alpha.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/one/Alpha.java] declares members with various access levels (public, private, protected). For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [AlphaTwo.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/two/AlphaTwo.java] is a subclass of Alpha but in a different package. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [DeltaOne.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/one/DeltaOne.java] has methods and variables that can be used by other classes in the same package. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [DeltaTwo.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/two/DeltaTwo.java] is not related to and is in a different package from {{Alpha}} so can access only the public members of Alpha. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Stack.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Stack.java] implements a stack (data structure) whose items are added and removed in a last-in-first-out (LIFO) fashion. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
h5.Inheritance
* [Planet.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Planet.java] contains one instance method and one class method. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Subclass.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Subclass.java] overrides a method and hides a variable in its super class. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Superclass.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Superclass.java] shows how to use super to invoke an overridden method. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
----
Learn about classes, member variables, methods, inheritance, nested classes, and more.
* Creating Classes
* Inheritance
h5.Creating Classes
* [AClass.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/AClass.java] declares an instance member variable, an instance method, a class variable, a class method, and main. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Alpha.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/one/Alpha.java] declares members with various access levels (public, private, protected). For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [AlphaTwo.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/two/AlphaTwo.java] is a subclass of Alpha but in a different package. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [DeltaOne.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/one/DeltaOne.java] has methods and variables that can be used by other classes in the same package. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [DeltaTwo.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/two/DeltaTwo.java] is not related to and is in a different package from {{Alpha}} so can access only the public members of Alpha. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Stack.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Stack.java] implements a stack (data structure) whose items are added and removed in a last-in-first-out (LIFO) fashion. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
h5.Inheritance
* [Planet.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Planet.java] contains one instance method and one class method. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Subclass.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Subclass.java] overrides a method and hides a variable in its super class. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
* [Superclass.java|http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Superclass.java] shows how to use super to invoke an overridden method. For supporting information see [The Java Tutorial: Classes and Inheritance|http://java.sun.com/docs/books/tutorial/java/javaOO/index.html].
----