Find out what variable is throwing a NullPointerException programmatically

后端 未结 8 1624
醉酒成梦
醉酒成梦 2020-12-05 10:30

I know I can find out if a variable is null in Java using these techniques:

  • if (var==null) -> too much work
  • try { ... } catch (Null
8条回答
  •  -上瘾入骨i
    2020-12-05 10:41

    I know you suggested that (var==null) is too much work, but, as Miguel stated in the comments, that is what I would go with.

提交回复
热议问题