0

this is what I have so far, but I'm having trouble with one line:

public class SFHashMap<Key, Value> {
    private static int size;
    private Entry<Key, Value>[] table;

    class Entry<Key, Value> {
        Key key;
        Value value;
        Entry next;

        public Entry(Key key, Value value, Entry<Key, Value> next) {
            this.key = key;
            this.value = value;
            this.next = next;
        }
    }

    public SFHashMap() {
        this(16);
    }

    public SFHashMap(int size) {
        this.size = size;
        table = new Entry[size]; **HERE**
    }
}

for table = new Entry[size];, I can't instantiate it as new Entry<Key, Value>[size] because I can't create generic arrays. What is the best way to go about this? Thanks

  • consider using `Set>` instead of an array. – Anantha Sharma Apr 06 '15 at 03:16
  • See [this](http://stackoverflow.com/a/23141780/2891664) and [this](http://stackoverflow.com/a/26927233/2891664). (Also looks like `class Entry` should probably be `static class Entry` in your case.) – Radiodef Apr 06 '15 at 03:41

0 Answers0