为什么我得到“可能的空指针取消引用"?警告? [英] Why do I get a "Possible null pointer dereference" warning?

查看:196
本文介绍了为什么我得到“可能的空指针取消引用"?警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么FindBugs向我提出以下警告: 可能会取消引用空指针 .

Why do FindBugs raises me the following warning: Possible null pointer dereference.

current = myService.getCategoryParent(current);
if (current != null) { // The warning appears here

我不明白如何针对null测试变量会取消对它的引用.

I don't understand how testing a variable against null could dereference it.

推荐答案

我怀疑错误/警告实际上是在您指示的行上 上.

I suspect the error/warning is actually on the line above the line you've indicated.

//                   here ------------v
current = myService.getCategoryParent(current);
if (current != null) {

这篇关于为什么我得到“可能的空指针取消引用"?警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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