Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String

Posted on 2006-06-08
4
Medium Priority
?
208 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 400 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 600 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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:
Suggested Courses

670 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