+ 5
What is difference between .equals() and .matches() when comparing strings.
any minor difference or no difference
7 ответов
+ 16
The method equals checks if two strings are identical. The method matches checks, if the string matches the regular expression you are passing.
If you have questions about a particular class, it is the best way to have a look at the javadoc, for String see
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
+ 14
@Tashi what is your age
+ 14
@Ekansh
I am stone-age. Some of my best friends were Neanderthal people.
+ 13
@salman Your definition for equals isn't correct. Look it up at the javadocs.
[Edit] Corrected his answer now 👍
+ 6
do u work for solo learn
+ 1
.equals() - check the two strings are equal.
.matches() - checks the regular expression or condition matched or not