About 4,930,000 results
Open links in new tab
  1. What is the difference between == and equals () in Java?

    Main difference between == and equals in Java is that "==" is used to compare primitives while equals() method is recommended to check equality of objects. String comparison is a common scenario of …

  2. How do I compare strings in Java? - Stack Overflow

    Apr 2, 2013 · The Java String class actually overrides the default equals() implementation in the Object class – and it overrides the method so that it checks only the values of the strings, not their locations …

  3. java - How the equals () method works - Stack Overflow

    Jul 12, 2021 · I am digging into the basics of Java. I infer from this article, that the Java 'equals' method means, if two objects are equal then they must have the same hashCode(). Here's my example. …

  4. Using the equals () method with String and Object in Java

    Sep 8, 2014 · The equals() Method of the Object class doesn't know how to compare Strings, it only knows how to compare objects. For comparing strings, a string class will override the equals() …

  5. What's the difference between ".equals" and - Stack Overflow

    Java String class actually overrides the default equals () implementation in the Object class – and it overrides the method so that it checks only the values of the strings, not their locations in memory.

  6. Метод equals() в Java - Stack Overflow на русском

    Dec 7, 2010 · Но вообще каждый раз при написании своего equals надо принимать во внимание тот факт, что когда-то создатели Java и класса java.lang.Object в частности написали условия, …

  7. Compare two objects with .equals() and == operator

    Feb 22, 2016 · Because with Java you can compare objects without first creating a Gson object and then calling toJson. Creating the Gson object and calling the logic needed to convert the actually …

  8. java - String.equals versus == - Stack Overflow

    Let's see it happen in Java terms. Here's the source code of String's equals() method: It compares the Strings character by character, in order to come to a conclusion that they are indeed equal. That's …

  9. java - How will Object's .equals and .hashCode will work for my classes ...

    Yes, the default implementation is Object's (generally speaking; if you inherit from a class that redefined equals and/or hashCode, then you'll use that implementation instead). From the documentation: …

  10. Comparing Java enum members: == or equals ()? - Stack Overflow

    I know that Java enums are compiled to classes with private constructors and a bunch of public static members. When comparing two members of a given enum, I've always used .equals(), e.g. public