I wonder if Java ever creates pointers to an other String.
One example where it could be a pointer:
App app = new App("name");
String name = app.getName();
If I after String name
is initialized change the value with app.setName("newName")
, String name
's value won't change.
This suggests that String name isn't a pointer but a new String.
But it could be, right? I mean it could be a pointer until either of the values (String name in App or String name) is changed to save memory?
So is it ever a pointer?
Not the same question as: String Interning Which specifically asks for explanation of String Interning. e.g String.intern()