Explain that Strings in Java are a weird-hybrid between a primitive and an Object and as a result they can’t be modified.

  • Draw students’ attention to the fact that Strings are Objects, but, because they can’t be modified, work more like a primitive when you initialize them and when you pass them between methods.
  • When you initialize a String in Java, it can look very similar to initializing an int!
    • String s = "cat"; int x = 7;
  • One way to help students recognize how strings are like Objects is to point out the need for using the keyword new when use the String constructor.
    • String s = new String("cat");
Diagram that shows how strings are represented in data like objects despite their declaration like primitives

More about this tip

External Source
Interview with Elissa Redmiles.