Click here to Skip to main content
15,886,755 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Please help me on converting the below inline if java code to if else.

C#
public boolean equals(final Object obj) {
      boolean result = true;
     
     if (level != null ? !level.equals(log.level) : log.level != null)
     {
          result = false;
     }
      
      return result;
  }
Posted

1 solution

Java
/**
* returns in inverse logic
*/
public boolean equals(final Object obj) { 
    if (null != level ){
        if(null != log.level){  // null check first
            if(false == level.equals(log.level))  {
                return false;
            }
        }
        return false; // log.level is null
    }
    return true; // equals
}


wired to return in inverse logic - you should change that.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900