I am able to handle null check on a String with this below piece of code
if (acct != null && !acct.isEmpty()|| !acct.equals(""))
what i mean from the above code is , if
- Accountid is not equal to null And
- Accountid length is greater than 0
(These two is a combination of checks )
Or
- Accountid is not equal to “”
Does my code satisfy these combination i mentioned above , or do i need to add any brackets ?? to satisfy the combination ( first 1 and 2 ) i mentioned above ??
Thanks
Yes it does, and is always evaluated before or, i.e. your code is the same as
However, logically it does not make sense to me. Do you really need the last part? Isn’t “acct.isEmpty()” the same as “acct.equals(“”))” in this specific instance?