View RSS Feed

Java String

All about Java String.

  1. Java String comparison with the compareTo method

    by , 04-26-2012 at 07:02 PM
    Also a less common 3rd way for comparison of the Java Strings is present. That method is CompareTo method, with string class. In case of two similar Java Strings, this method will be returning a zero value. String Comparison approach shall look like this given example:

    Java Code:
    String string1 = "foo bar";
    String string2 = "foo bar";
    
    // java string compare example
    if (string1.compareTo(string2) == 0)
    {
      // this line WILL
    ...
    Categories
    Compare