Vector ArrayIndexOutOfBounds
- by Esmond
I'm having an ArrayIndexOutofBounds exception with the following code.
The exception is thrown at the line where  Node nodeJ = vect.get(j) 
but it does not make sense to me since j is definitely smaller than i and  Node nodeI = vect.get(i)  does not throw any exception.
any help is appreciated.
public static Vector join(Vector vect) throws ItemNotFoundException {
    Vector<Node> remain = vect;
    for (int i = 1; i < vect.size(); i++) {
        Node nodeI = vect.get(i);
        for (int j = 0; j < i; j++) {//traverse the nodes before nodeI
            Node nodeJ = vect.get(j);
            if (nodeI.getChild1().getSeq().equals(nodeJ.getSeq())) {
                nodeI.removeChild(nodeJ);
                nodeI.setChild(nodeJ);
                remain.remove(j);
            }
            if (nodeI.getChild2().getSeq().equals(nodeJ.getSeq())) {
                nodeI.removeChild(nodeJ);
                nodeI.setChild(nodeJ);
                remain.remove(j);
            }
        }
    }
    return remain;
}