Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 8th, 2013, 02:11 PM
DimmestLemming DimmestLemming is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 70 DimmestLemming User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 17 m 16 sec
Reputation Power: 3
Homework - Trouble with inheritance + methods that take in generics

I'm having problems overriding a method from an interface that takes in a generic type.

The code from my interface looks like this:

public interface KDTree<E extends Location> {
...
void insert(E element);
...
}

And for the class:

public class BulkInsertKDTree<E extends Location>
implements KDTree, Iterable {
...
@Override
public void insert(E element) {
//Code
}
...
}

The compiler gives me 2 different errors:

error: BulkInsertKDTree is not abstract and does not override abstract method insert(Location) in KDTree

error: name clash: insert(E#1) in BulkInsertKDTree and insert(E#2) in KDTree have the same erasure, yet neither overrides the other

It seems like the compiler isn't equating the second insert with the first because each one takes in a generic type, and java doesn't recognize that the two are treated the same way. Is there any way I can fix this?

Thanks!

Reply With Quote
  #2  
Old February 8th, 2013, 02:20 PM
Aurum84 Aurum84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 74 Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 23 h 5 m 49 sec
Reputation Power: 17
Just a wild guess, but in the interface the method is declared private, while in the implementing class it is declared as public. What happens if you make the access levels equal?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Homework - Trouble with inheritance + methods that take in generics

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap