About 51 results
Open links in new tab
  1. How do I compare strings in Java? - Stack Overflow

    Apr 2, 2013 · At the end of this Java String comparison tutorial I'll also discuss why the "==" operator doesn't work when comparing Java strings. Option 1: Java String comparison with the equals method …

  2. 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 …

  3. String Comparison in Java - Stack Overflow

    Oct 31, 2010 · If you check which string would come first in a lexicon, you've done a lexicographical comparison of the strings! Some links: Wikipedia - String (computer science) Lexicographical …

  4. What is the difference between == and equals () in Java?

    For String s, == is reference equals as well, yes, but it usually works (as in two String s with the same content will usually be == to each other), because of how Java handles String s.

  5. java - compareTo () vs. equals () - Stack Overflow

    Oct 11, 2019 · This is an old question, but it contains a nugget I wanted to highlight: " compareTo() == 0 does not necessarily imply equality in all cases". This is absolutely correct! This is exactly what the …

  6. What's the quickest way to compare strings in Java?

    Sep 27, 2010 · What's the quickest to compare two strings in Java? Is there something faster than equals? EDIT: I can not help much to clarify the problem. I have two String which are sorted …

  7. How do I make my string comparison case-insensitive?

    Feb 8, 2010 · 29 String.equalsIgnoreCase is the most practical choice for naive case-insensitive string comparison. However, it is good to be aware that this method does neither do full case folding nor …

  8. Compare two objects in Java with possible null values

    Since String is final, even the simplest JVMs will be capable of inlining that code, not to speak of modern common implementations. So if the strings are identical (equal and interned), the early reference …

  9. java string comparison (equals vs. ==) - Stack Overflow

    Oct 27, 2012 · Possible Duplicate: How do I compare strings in Java? Demonstrating string comparison with Java I am getting confused by the very basics here. Since I've started using java I was always …

  10. java - Why doesn’t == work on String? - Stack Overflow

    Jul 3, 2013 · In Java, strings are objects (String). Variables which contain objects are references. If you compare two objects with == operator, true is returned only if they are the same objects (in memory). …