Java short circuit evaluation

后端 未结 7 1502
深忆病人
深忆病人 2021-01-07 23:26

I thought Java had short circuit evaluation, yet this line is still throwing a null pointer exception:

if( (perfectAgent != null) && (perfectAgent.ge         


        
7条回答
  •  温柔的废话
    2021-01-07 23:41

    There are three references other than perfectAgent that could be null:

    • perfectAgent.getAddress()
    • entry
    • entry.getKey()

    Break up the statement or run it in a debugger.

提交回复
热议问题