Java short circuit evaluation

后端 未结 7 1438
深忆病人
深忆病人 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:57

    Try formatting your code like this:

    if( 
      (perfectAgent != null) 
      && (
          perfectAgent.getAddress()
          .equals(
           entry.getKey()
          )
         ) 
      ) {
    

    It should give you a better stack trace line entry.

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