About 50 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 …

  2. Comparing some strings in Java - Stack Overflow

    Aug 5, 2023 · Comparing by == tells you only if two references points to same object. And in your example that's it: string2 and string3 points to same instance of string "Hi" (why should Java …

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

  4. java - How to compare multiple strings? - Stack Overflow

    Nov 20, 2013 · Two things wrong: You can't just specify multiple values with || (or &&) like that. You need to specify both the left side and the right side explicitly each time. Second, use …

  5. Comparing two Strings using Java 8 features - Stack Overflow

    I was exploring various efficient ways to compare two strings in Java and I was comparing below two code snippets Approach 1 :- Traditional Way public static boolean stringCheck(String …

  6. String Comparison in Java - Stack Overflow

    Jan 5, 2017 · The Java String class provides the .compareTo () method in order to lexicographically compare Strings. It is used like this "apple".compareTo ("banana"). The …

  7. Java get String CompareTo as a comparator object

    Aug 4, 2012 · 56 I would like to sort and binary search a static array of strings via the String.CompareTo comparator. The problem is that both sorting, and binary searching requires …

  8. Java, how to compare Strings with String Arrays

    Jan 20, 2012 · I know one can easily compare Strings by using the .equals () method. However, the same method is not working with the String array. I created the following example of code …

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

    Sep 27, 2010 · In my application I am using String constants and store strings in collections. Multiple comparisons of strings using my method are actually faster for me, but it may not be …

  10. java - How to compare Strings in if-else statements? - Stack …

    Oct 7, 2011 · How to compare Strings in if-else statements? Asked 14 years, 4 months ago Modified 14 years, 4 months ago Viewed 20k times