String

is String a primitive type? as in.. if i do deep cloning..
do i need to specifically clone String, regarding it as a mutable field like i.e Date
jedistarAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
StillUnAwareConnect With a Mentor Commented:
String is not primitive, but is some kind of special type, it is usually used internally by Java as if it was primitive. In Your case, You don't need to provide explicit cloning when doing a deep copying. As a user You will notice that after cloning object having strings as fields, will copy every string values too, on the other hand in memory (constant pool) there will be only one similar character sequence, which will be refered by more than one string object.

Anyway, You DON'T have to manually copy string bytes to implement deep copying, in this case You may interpret it as primitive type.
0
 
ksivananthCommented:
no, its a special type of object
0
 
ksivananthCommented:
just strng.toString() going to give you value equvalent to deep cloning
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.