facebook

Type safey warning

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #265718 Reply

    maximuszen
    Member

    Type safety: The method add(Object) belongs to the raw type Collection. References to generic type Collection<E> should be parameterized

    It seems to occur when I use either Hashtable or HashMap

    private HashMap actions;

    /**
    * @throws ServletException
    */
    public void init() throws ServletException {

    CreateNewUser createNewUser = new CreateNewUser();
    actions.put(“CreateNewUser”.toLowerCase(), createNewUser);

    #265750 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

    You either need to turn off 1.5 support and don’t use generics, or you have to define your hash table key/value types using types. like:
    Map<String, CreateNewUser> actions = new HashMap<String, CreateNewUser>();

    that notation might not be right, I’m doing it from memory.

    #265757 Reply

    maximuszen
    Member

    Riyad,

    Can you tell me the exact notation? I don’t know so… I don’t want to just try random syntax to get it right.

    John

    #265768 Reply

    Riyad Kalla
    Member

    John,
    If you don’t know generics I would suggest turning off Java 5 support otherwise you are going to continue to get those warnings everywhere. So me helping with this one instance is a very temporary solution.

    Or pickup a tutorial real quick on the subject, but I imagine you’d rather just get work done interruption-free at the moment.

    I’ll be honest with you, I didn’t start using generics until about 3 months ago and I’m still alive, so it’s not necessary 😀

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Type safey warning

You must be logged in to post in the forum log in