Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

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
0
jedistar
Asked:
jedistar
  • 2
2 Solutions
 
objectsCommented:
0
 
ksivananthCommented:
no, its a special type of object
0
 
ksivananthCommented:
just strng.toString() going to give you value equvalent to deep cloning
0
 
StillUnAwareCommented:
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now