Solved

String

Posted on 2006-06-08
4
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 16865907
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16865913
no, its a special type of object
0
 
LVL 26

Expert Comment

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

Accepted Solution

by:
StillUnAware earned 150 total points
ID: 16865932
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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:

749 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