Why String is immutable in Java

Tutorials Shared by the Internet Community

Advertisements

  Top Tutorials     New Tutorials     Submit     Login     Register  

Tutorial Detail

Why String is immutable in Java


http://javarevisited.blogspot.com/2010/10/why-string-is-immutable-in-java.html
  • Total Hits: 20885

  • Average Rating :
    URL RatingURL RatingURL RatingURL RatingURL Rating

  •  

  • Total Votes: 156 votes

  • Category: Computer Basics/Computer Basics

  • Submitted on: 2011-01-22 15:39:34

  • Submitted By: Javin Paul

  • Set as Favorite

Description:

This is one of the most popular interview question on String in Java which starts with discussion of What is immutable object , what are the benefits of immutable object , why do you use it and which scenarios do you use it.

It can also come once interviewee answers some preliminarily strings questions e.g. What is String pool , What is the difference between String and StringBuffer , What is the difference between StringBuffer and StringBuilder etc.

Though there could be many possible answer for this question and only designer of String class can answer this , I think below two does make sense    More detail...

Rating Detail

 Stars  Percentage  Total Vote
 One star  Vote LeftVote MiddleVote Right 36.54%  57
 Two starsTwo star  Vote LeftVote MiddleVote Right 10.26%  16
 Three starsThree starsThree stars  Vote LeftVote MiddleVote Right 11.54%  18
 Four starsFour starsFour starsFour stars  Vote LeftVote MiddleVote Right 11.54%  18
 Five starsFive starsFive starsFive starsFive stars  Vote LeftVote MiddleVote Right 30.13%  47

Caste Your Vote

 Rating  Selection  Guidelines
 Poor:     Very disappointing, useless.
 Fair:     Below average, disappointing but not useless.
 Good:     About average in its class.
 Very Good:     Above average for its category.
 Excellent:     One of the best Tutorials in its category.






Advertisements