+ 1
Differentiate between compareTo() and equals().
this question cost me class highest in preboards.... 😭😭😭😭
2 ответов
+ 5
compareTo() returns -1, 0, & 1 for <, =, & >. It lets you perform <= and >= by using the normal operators with 0.
equals() returns true when both have same value and false otherwise.
+ 4
https://www.leepoint.net/data/expressions/22compareobjects.html
https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html
https://www.tutorialspoint.com/java/java_string_compareto.htm
https://www.javatpoint.com/java-string-compareto
https://beginnersbook.com/2013/12/java-string-compareto-method-example/
https://www.javatpoint.com/java-string-equals
https://www.javaworld.com/article/2072762/java-app-dev/object-equality.html