How can I express that two values are not equal to eachother?

后端 未结 4 2030
傲寒
傲寒 2020-12-31 08:06

Is there a method similar to equals() that expresses \"not equal to\"?

An example of what I am trying to accomplish is below:

if (second         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 08:31

    "Not equals" can be expressed with the "not" operator ! and the standard .equals.

    if (a.equals(b)) // a equals b
    if (!a.equals(b)) // a not equal to b
    

提交回复
热议问题