Skip to Main Content

Java Programming

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!

Raw type hashtable

807569May 17 2006 — edited May 17 2006
Hi,

I am migrating some code from 1.4.2 to 1.5.0 but I am stopped by hashtable issue:
public class MyClass {
private static Hashtable ht = null;
private int id;
private String sID;

public MyClass() {
      ht = new Hashtable();
      id = 0;
    }


public String subscribe(int i, MyObject event) throws Exception {
try {
            id++;
            Integer type = new Integer(event);
            Hashtable group = (Hashtable)ht.get(type);
            if (group == null) {
                group = new Hashtable();
                ht.put(type, group); // 1)
            }
            sID = type.toString() + new Integer(id).toString();
            group.put(sID, event); // 2)
            return sID;
        }
        catch (Exception exc) {
            throw new NestedException(exc, "ERROR: bla bla bla bla");
        }
}

public boolean unSubscribe(String sID) throws Exception {
        try {
            Enumeration g = ht.elements();
            while (g.hasMoreElements()) {
                Hashtable group = (Hashtable)g.nextElement();
                if (group.remove(sID) != null)
                        return true;
            }
            return false;
        }
        catch (Exception exc) {
            throw new NestedException(exc, "ERROR: bla bla bla bla");
        }

    }
1) Type safety: The method put(Object, Object) belongs to the raw type Hashtable. References to generic type Hashtable<K,V> should be parameterized

2) Type safety: The method put(Object, Object) belongs to the raw type Hashtable. References to generic type Hashtable<K,V> should be parameterized


Could you help me with this?
I am really being under pressure with this.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 14 2006
Added on May 17 2006
16 comments
306 views