Java code evaluation (IntelliJ IDE), use toString() in some point?

前端 未结 2 865
清歌不尽
清歌不尽 2021-02-01 15:21

When evaluating object initialization, toString nullPointerException appear.

Method threw \'java.lang.NullPointerException\' exception. Cannot evaluate XX

相关标签:
2条回答
  • 2021-02-01 15:24

    Maybe you override the hashCode() method and hashCode() return null.

    0 讨论(0)
  • 2021-02-01 15:33

    I have discovered the root cause for this behavior.

    You can choose in what way IntelliJ evaluation will display the data: the result can be the Object or toString evaluation. Therefore the error i had experienced, View as->toString was used, while not all the objects had toString implemented. Hope it will help someone in the future.

    enter image description here

    If you don't want to update it manually each time, you can change it in IntelliJ properties following this steps

    0 讨论(0)
提交回复
热议问题