Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2004

Tip: Looking for answers? Try searching our database.

help with generics

Thread view: 
David - 29 Sep 2004 13:32 GMT
Hello,
I try to model the following structure:
A DomainModel has several Concepts as sons and
a Concept has several Categories as sons and
a Category may also have Categories as sons.
I modeled it like that:

public abstract class DomainModelElement<C extends DomainModelElement>
implements DomainModelTokens {
 protected Vector<C> children = new Vector<C>();
..
public class DomainModel extends DomainModelElement<Concept> {
..
public class Concept extends DomainModelElement<Category> {
..
public class Category extends DomainModelElement<Category> {  
..

So I pass the child type to the element, so I can use generic
implementations
of the methods for accessing the children. When I compile everything
works fine
until the compiler see the Category class. It says:

Bound mismatch: The type Category is not a valid substitute for the
bounded parameter <C extends DomainModelElement> of the type
DomainModelElement<C>    Category.java

although Category is a subclass of DomainModelElement<C>.
Can anybody help?

  Thanks beforehand,
          David Kensche
Larry Barowski - 29 Sep 2004 19:43 GMT
> ...
> public abstract class DomainModelElement<C extends DomainModelElement>
[quoted text clipped - 12 lines]
> bounded parameter <C extends DomainModelElement> of the type
> DomainModelElement<C> Category.java

What version of Java are you using? This seems to work fine
in 1.5.0 rc.
David - 30 Sep 2004 08:26 GMT
> What version of Java are you using? This seems to work fine
> in 1.5.0 rc.
Hi,
I am using jdk1.5.0. Don't know what rc stands for but
this should be the same, shouldn't it?

 David
Tor Iver Wilhelmsen - 30 Sep 2004 09:05 GMT
> I am using jdk1.5.0. Don't know what rc stands for but
> this should be the same, shouldn't it?

RC = release candidate, which was the last version available before
the now-available final release.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.