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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extends

Status
Not open for further replies.

crmayer

Programmer
Nov 22, 2002
280
US
I have created a class that extends another class that I need. Once I have started getting close to being done, I see that I also need to use an autoincrement method that is in another class. From what I understand you can only extend one class. How can I access that other method without extending that class? Is this possible?
 
Well, one way is to create an instance of the class object that uses the autoincrement that you want to use. Then you can use your new class to call that autoincrement method when you need it. That's a simple way to get around the problem.

Hope that helps.

Nick Ruiz
Webmaster, DBA
 
I remember experiencing similar confusion when I started learning Java.

A thing to bear in mind is that you should normally only extend a class if you intend to modify its behaviour in some fashion. You wouldn't extend it simply to call its methods. Creating an instance of a class and invoking the methods on that instance is the way to go.

Might be worth having a shuffle through forum678 (Object-Oriented Analysis and Design) for some good advice on how to approach writing OO software.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top