Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java: I am trying to create an Entry class for a hashtable with generic key/v

ID: 3827257 • Letter: I

Question

In Java: I am trying to create an Entry class for a hashtable with generic key/value types. The Entry class must have an integer next field that indexes the next element in a chain(where next is not an object pointer). Essentially, I need to create linked list of entries using indices rather than pointers. I have tried using Entry<K,V> next; in my Entry class but I think that is a pointer right? Ive also tried:
______________________________
static private class Entry<K,V>{
protected K key;
protected V value;
ArrayList<V> entryList = new ArrayList<V>(1);

public Entry(K k1, V v1, int next){
key = k1;
value = v1;
next = key.hashCode() % entryList.size();
entryList.add(next, value);
}
}

I don't believe this is correct, how would I set up this Entry class so that I have the integer next field?

Explanation / Answer

Please let me know in case of any issue.

static class Entry<K, V> {
K key;
V value;
Entry<K,V> next;

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


this is the main array

[Entry] Entry Entry here is the linked-list
[Entry]
[Entry] Entry
[Entry]
[null ]
[null ]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote