java - Cannot invoke equals(boolean) on the primitive type boolean -


i want check equality of first , last 2 characters of string have written condition like

if (str.length() >= 4             && ((str.startswith(str.substring(0, 2))).equals(str.endswith(str                     .substring(str.length() - 3, str.length() - 1))))) 

but getting error cannot invoke equals(boolean) on primitive type boolean

so root cause?

error coming because : str.startswith() returns boolean value , calling equals() boolean

use expression compare :

    str.substring(0, 2).equals(str.substring(str.length() - 3, str.length() - 1)) 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -