Java strings

  1. String in NOT a fundamental type in Java.

  2. Recall there are only TWO different categories of types in Java:

    Conclusion: Strings are objects in Java

    So Strings in Java are stored linke this:

    which is exactly equal to creating an object: click here

  3. The java.lang.String class documentation: click here ( local copy)

    Notice the many help functions defined for String...
            Compare methods, Substring methods, Case conversion methods, etc. etc.

  4. Because strings are used frequently, Java have many "short hands" for Strings...

    Operation Offical syntax Short hand for Strings
    Create new String object   new String("text")   "text"
    Staring variable initialization   String x = new String("text");   String x = "text";
    String concatenation     "text1" + "text2"

    Note: you can also use the "official syntax" for Strings if you so desire...

    Example program defining & concatenating Strings: click here DEMO