aspose file tools*
The moose likes Beginning Java and the fly likes inheritance question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inheritance question" Watch "inheritance question" New topic
Author

inheritance question

ilteris kaplan
Ranch Hand

Joined: Jan 21, 2006
Posts: 38
Hello Hunters;

I am trying to implement inheritance in my application and here is the deal.

I have a Tag class that gets data tag etc. as its constructor, and I have a displayTag class which I want to both be subclass of my Tag class so that it could get the variables and methods that Tag have and plus I want it to extend PApplet class so that I could use processing methods in this displayTag class. (it is the main reason I am separating the tag and tagDisplay classes.

So when I try to do something like;

public class TagDisplay extends PApplet extends Tag {
TagDisplay(String sUrl_,int numOfApp_, String tag_, String descrpath_) {
super(sUrl_, numOfApp_, tag_, descrpath_);
}

}

well it doesn't work... what am I missing here? Also one other question is eclipse is throwing me this warning of "The serializable class TagDisplay does not declare a static final serialVersion UID field of type long" and advices me to create this line of code :

/**
*
*/
private static final longserialVersionUID= 3082584054442772747L;



Can someone explain what is going on here?

best
ilteris.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

Ilteris,
Java only allows single inheritance - in other words you can only extend one class at a time.

A common way around this is to instantiate a Tag within your DisplayTag class and use the methods that way. Another common way is to use an interface - but that wouldn't work here - you want the functionality.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

See this thread for the serialVersionUID part of your question.
ilteris kaplan
Ranch Hand

Joined: Jan 21, 2006
Posts: 38
Thank you for the quick response Jeanne!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inheritance question