Yahoo India Web Search

Search results

  1. Aug 5, 2014 · 0. Mutable means you will save the same reference to variable and change its contents but immutable you can not change contents but you will declare new reference contains the new and the old value of the variable. Ex Immutable -> String. String x = "value0ne";// adresse one.

  2. Jun 23, 2012 · Mutable strings in Java. Ask Question Asked 12 years, 4 months ago. Modified 12 years, 4 months ago ...

  3. Super late to the answer, but wanted to put a concise message from author of the String class in Java . Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared.

  4. Mar 14, 2014 · 12. IMHO, this is the most important reason: String is Immutable in Java because String objects are cached in String pool. Since cached String literals are shared between multiple clients there is always a risk, where one client's action would affect all another client. Ref: Why String is Immutable or Final in Java.

  5. Jan 10, 2012 · String is immutable ( once created can not be changed ) object . The object created as a String is stored in the Constant String Pool. Every immutable object in Java is thread safe ,that implies String is also thread safe . String can not be used by two threads simultaneously. String once assigned can not be changed.

  6. Jun 22, 2012 · 1) Go to jdk installation and copy to separate folder rt.jar and src.zip. 2) Unpack String.java from sources zip and change it private field value of inner char array to public. public final class String. implements java.io.Serializable, Comparable<String>, CharSequence {. /** The value is used for character storage.

  7. Nov 11, 2008 · 3. Immutable means that once the object is created, non of its members will change. String is immutable since you can not change its content. For example: String s1 = " abc "; String s2 = s1.trim(); In the code above, the string s1 did not change, another object (s2) was created using s1.

  8. Jan 6, 2014 · So, in "reality", no they are not absolutely immutable. To point 2: This is because substring is probably allocating a new string instance, which is likely copying the array. It is possible to implement substring in such a way that it won't do a copy, but that doesn't mean it does. There are tradeoffs involved.

  9. Jun 8, 2014 · There are a couple of minor downsides for immutable types: Operations that create a changed string like concatenation are more expensive because you need to construct new objects. Typically the cost is O (n+m) for concatenating two immutable Strings, though it can go as low as O (log (m+n)) if you use a tree-based string data structure like a ...

  10. Sep 18, 2008 · In some older Java implementations you could do that, and I found a snippet of code that used that to internalize strings (try to locate other internal string that has the same value, share the pointer, remove the old memory block) and used the backdoor to rewrite the string contents forcing an incorrect behavior in a different class. (Consider rewriting "SELECT *" to "DELETE ")

  1. People also search for