Results 1 to 3 of 3
  1. #1
    w95
    w95 is offline Member
    Join Date
    May 2011
    Posts
    12
    Rep Power
    0

    Default Generic Interface

    Hello!
    Trying to write a interface for a vector class i have to implement,getting some errors tho,and dont know what im doing wrong.
    Hope some1 can point me in the right direction!

    Java Code:
    public interface IVector <T>
    {
    	void add(T elem);
    	void add(T elem, int pos);
    	int capacity(); 
    	void clear(); 
    	boolean contains(Object elem);
    	int indexOf(T elem);
    	boolean isEmpty();
    	boolean remove(int pos); 
    	boolean remove(Object elem);
    	T elementAt(int pos);
    	void insertElemenAt(T elem, int pos);
    	void setElementAt(T elem, int pos);
    	int size();	
    }
    the error im getting is "T cannot be resolved to a type"

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,048
    Blog Entries
    7
    Rep Power
    23

    Default

    Which line is causing that error? It compiles fine for me. Are you using Java 1.5 or later?

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    w95
    w95 is offline Member
    Join Date
    May 2011
    Posts
    12
    Rep Power
    0

    Default

    It complained about every line with T in it.
    Restarted the IDE,and now i get no errors,weird bug;( wasted like 2 hours googling the interweb for a answer tho:(

    Sorry for a uneccesary post.

Similar Threads

  1. comparable interface, generic types
    By dylandrop in forum New To Java
    Replies: 3
    Last Post: 04-16-2011, 07:45 PM
  2. Can generic types implement an interface?
    By jdgallag in forum New To Java
    Replies: 3
    Last Post: 10-30-2008, 05:07 AM
  3. A generic interface example
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •