com.sun.jdi.InvocationException occurred invoking method

前端 未结 16 1279
迷失自我
迷失自我 2020-12-13 01:38

I just want to create an object of class, but got this error when debugging. Can anybody tell me what the problem is? The location of this code is in some Spring(2.5) Servic

16条回答
  •  渐次进展
    2020-12-13 01:57

    For me the same exception was thrown when the toString was defined as such:

    @Override
    public String toString() {
        return "ListElem [next=" + next + ", data=" + data + "]";
    }
    

    Where ListElem is a linked list element and I created a ListElem as such:

    private ListElem cyclicLinkedList = new ListElem<>(3);
    ListElem cyclicObj = new ListElem<>(4);
    ...
    
    cyclicLinkedList.setNext(new ListElem(2)).setNext(cyclicObj)
        .setNext(new ListElem(6)).setNext(new ListElem(2)).setNext(cyclicObj);
    

    This effectively caused a cyclic linked list that cannot be printed. Thanks for the pointer.

提交回复
热议问题