[go: up one dir, main page]

0% found this document useful (0 votes)
1 views1 page

String

Uploaded by

sanjeevsingh9517
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

String

Uploaded by

sanjeevsingh9517
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

STRING

String is a collection of character. String is the immutable object. Immutable


means not changeable.

Creating String object


1. String s1= new String("ACE");
2. String s2="ACE"

When the string object is created with the help of new keyword then one object is
created in HEAP MEMORY and another object id created in SCP (String Constant Poll)
area.

Reference of object which is created in HEAP MEMORY have reference variable but
reference of object in SCP does not have.

When the object in HEAP MEMORY does not have reference variable then this object
will be destroyed by GARBAGE COLLECTOR. Man this object will be destroyed by the
JVM.

But JVM does not destroyed the object which does not have reference variable in
SCP. Because internally JVM maintain the reference variable for the object created
in SCP.

You might also like