samedi 21 février 2015

How come printing a string(an Object) in java prints it?

When we do:



String string = new String("Ralph");
//This creates a reference called string that points to a sequence of
//characters in memory


This is the same as:



String string = "Ralph";


When we print both, we get the actual value of the string. If we print any other object in Java, we get an address for that object. My question is, is there any dereferencing that is taking place behind the scenes?


Aucun commentaire:

Enregistrer un commentaire