Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generic inheritance

843793Jan 19 2005 — edited Jan 19 2005
When I use the code:
import java.util.*;

    class BagTest<E> extends LinkedList<E> {
   
   /** Add object to bag 
   * @param ob the object to add
   */  
       public void add(E ob) {
         super.addLast(ob);
      }
   
   }
I get the error:
BagTest.java:8: add(E) in BagTest cannot implement add(E) in java.util.Collection; attempting to use incompatible return type

Now I know that add in Collection is boolean, but I'm either overriding or creating a new method ???
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2005
Added on Jan 19 2005
1 comment
51 views