Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does it mean by extends

Status
Not open for further replies.

Creeder

Programmer
Jul 5, 2000
110
MY
Hi All,

What does the keyword extends means? Example

public class TEST extends AnotherClass
{

}

Does that mean now class TEST have the methods of the class
AnotherClass??

Thanks

YJ
 
This is a very important concept in java: inheritance. "Extends" is a keyword meaning that the TEST class inherits the fields and methods of AnotherClass. TEST is a subclass of AnotherClass. For example, you might have a class called Shapes with subclasses of Circle, Square, Triangle, etc. They all have areas, but do not use the same formula to calculate the areas. This is object oriented programming (OOP). You should read about it. Remove "nospam" from my email address to reply.
 
If you come from a c++ enviroment, this is basically the same syntax if you did
Code:
class human : public mammal
{

human() : mammal()
{

} 
};
ackka
ackka@mad.scientist.com
duke_wave.gif
Java is the Future
 
Yes, it means that TEST (should be Test) has all the methods and properties of AnotherClass.

You can add properties and methods to Test that extend the functionality of AnotherClass. You can also redefine methods of AnotherClass to do something a different way.

hth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top