The life of the Java object is not the same as the basic type. When you use New to generate a Java object, even if you leave the living space, the object still exists. So if you write this:
{String S = New String ("a string");
} / * End of scope * /
S. This Reference will disappear from outside the living space. However, the String object that is previously referred to will continue to take up memory. But just look at the program code above, you can't access the object, because the only thing to point to it, has left its living space