!= string version

I know that the version for objects or strings of == is string1.equals(string2) but what is the string/object version for !=?


  • `"if ( ! (string1.equals(string2)) ) {....}"

    or if you don't care about letter cases, use this..

    "if ( ! (string1.equalsIgnoreCase(string2)) ) {....}" `


    public boolean equals(Object anObject)
    **anObject **-- the object to compare this String against.

    Return Value :
    This method returns true **if the String are equal; **false otherwise.

    So do a if(string1.equals(string2)==0) means if they are not equal.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion