Difference between matches and equalsIgnoreCase or equals in string class

后端 未结 5 811
一整个雨季
一整个雨季 2020-12-29 09:44

matches: Will check if the complete string entered is equal to the value present in the string object.

equalsIgnoreCase: Ignoring t

5条回答
  •  温柔的废话
    2020-12-29 10:03

    There is a big difference - matches checks the match of a String to a regular expression pattern, not the same string. Do not be mislead by the fact that it receives a String as an argument.

    For example:

    "hello".equals(".*e.*"); // false
    "hello".matches(".*e.*"); // true
    

提交回复
热议问题