Java代码评估(IntelliJ IDE),在某些方面使用toString()? [英] Java code evaluation (IntelliJ IDE), use toString() in some point?

查看:148
本文介绍了Java代码评估(IntelliJ IDE),在某些方面使用toString()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在评估对象初始化时,会出现toString nullPointerException。

When evaluating object initialization, toString nullPointerException appear.


方法抛出'java.lang.NullPointerException'异常。无法评估XXXX.toString()

Method threw 'java.lang.NullPointerException' exception. Cannot evaluate XXXX.toString()

重新创建此问题的代码示例:

Code example which recreates this issue:

Car car = carUtils.objectMapper.readValue(new File(pathTo("carProperties.json")), Car.class); 

为什么会这样?是使用toSting()调用完成的评估?

Why is that happens? is the evaluation done using toSting() invocations?

推荐答案

我发现了这种行为的根本原因。

I have discovered the root cause for this behavior.

您可以选择IntelliJ评估将以何种方式显示数据:结果可以是对象或toString评估
因此我遇到了错误,使用了View as-> toString,而并非所有对象都实现了toString。
希望将来会帮助某人。

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.

如果您不想每次手动更新它,可以在IntelliJ属性中更改它按照以下步骤进行操作

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

这篇关于Java代码评估(IntelliJ IDE),在某些方面使用toString()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆