Note that there are some explanatory texts on larger screens.

plurals
  1. POArrayOutOfBoundsException thrown when using Hash iterator
    primarykey
    data
    text
    <p>I wrote my own Hash class, which I then used to store (String, LinkedList(String)) pairs as the (K,V) pairs. When i call the program to fill the hash, an ArrayOutOfBoundsException is thrown in the iterator. I have tried making the array much larger than needed, but still encounter the same error. The line where the error is thrown is "nodes[j++] = n;" </p> <pre><code>abstract class IteratorHelper&lt;E&gt; implements Iterator&lt;E&gt; { public DictionaryNode&lt;K,V&gt;[] nodes; protected int index; protected long modCheck; public IteratorHelper() { nodes = new DictionaryNode[currentSize]; index = 0; int j = 0; modCheck = modCounter; System.out.println("int currentSize = " + currentSize); System.out.println("int tableSize = " + tableSize); for(int i=0; i&lt;tableSize; i++) for(DictionaryNode n : list[i]) { System.out.println("int j = " + j); System.out.println("DictionaryNode key at nodes[" + j + "] = " + n.key); nodes[j++] = n; } nodes = (DictionaryNode&lt;K,V&gt;[]) Sorter.quickSort(nodes); } public boolean hasNext() { if(modCheck != modCounter) throw new ConcurrentModificationException(); return index &lt; currentSize; } public abstract E next(); public void remove() { throw new UnsupportedOperationException(); } } class KeyIteratorHelper&lt;K&gt; extends IteratorHelper&lt;K&gt; { public KeyIteratorHelper() { super(); } public K next() { return (K) nodes[index++].key; } } class ValueIteratorHelper&lt;V&gt; extends IteratorHelper&lt;V&gt; { public ValueIteratorHelper() { super(); } public V next() { return (V) nodes[index++].value; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload