Solved

String

Posted on 2006-06-08
4
200 Views
Last Modified: 2010-03-31
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
Comment
Question by:jedistar
  • 2
4 Comments
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
Comment Utility
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
no, its a special type of object
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
just strng.toString() going to give you value equvalent to deep cloning
0
 
LVL 14

Accepted Solution

by:
StillUnAware earned 150 total points
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now