Reference+
Name
equals()
Class
String
Description
Compares two strings to see if they are the same. This method is necessary because it's not possible to compare strings using the equality operator (==). Returns true if the strings are the same and false if they are not.
Examples
String str1 = "CCCP"; String str2 = "CCCP"; // Tests to see if 'str1' is equal to 'str2' if (str1.equals(str2) == true) { println("Equal"); // They are equal, so this line will print } else { println("Not equal"); // This line will not print }
Syntax
str.equals(str)
Parameters
str
String: any valid String
Return
Boolean

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.