Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 579 Bytes

File metadata and controls

19 lines (15 loc) · 579 Bytes

Equality ignoring case

If you want to check if two Strings contain the same contents but you do not care if those contents differ in the casing of letters, you can use the .equalsIgnoreCase method.

void main() {
    String historicalFigureOne = "St. Valentines";
    String historicalFigureTwo = "st. valentines";

    IO.println(
        historicalFigureOne.equalsIgnoreCase(historicalFigureTwo)
    );
}

This is different from the result the .equals method will give you. That method will return false if there are any differences in the two Strings.