string is immutable? right every one knows that, my
question is it advantage or disadvantage making string
immutable?
Answers were Sorted based on User's Feedback
Answer / payal gupta
It is an advantage that a String class is immutable because
almost all the standard classes use its methods, if they
were mutable, then the behaviour of other standard classes
and their methods would not have been consistent.
| Is This Answer Correct ? | 7 Yes | 7 No |
Answer / vinod kumar
It is an advantage
performance: knowing that a string is immutable makes it
easy to lay it out at construction time — fixed and
unchanging storage requirements
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / prashant renge
It is advantage,
because String is standard class,if it is muttable
behaviour is inconsistant.
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / chandu
Sting is Immutable.We can make String as mutable in the give ex
String s="Hello";
String s=s1;
String s2;
s2=s1.append("World");
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / ashish balhara
The performance for String is poor as compared to String
Buffer, as internally (for eg. a simple operation like + on
String), it generates String Buffer, calls append operation
(eqvt. of + in String) & converts result back to String.
Hence extra bytecode is generated which could be done away
with.
| Is This Answer Correct ? | 0 Yes | 5 No |
What is contract between hashcode and equal method?
What is binary search in java?
Does constructor be static?
What are the 5 types of research methods?
2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?
1.) if we use "private" in place of "public" in public static void main()... 2.) if we use "int" in place of "void".... 3.) can we ommit "static" keyword from that statement.... 4.) also can we give the command line arguments type as int type or float,etc.(.i.e (string args[]))
How much ram can a 64 bit processor theoretically?
What is deadlock and how to avoid this?
What is polymorphism in java? What are the kinds of polymorphism?
What is encapsulation? Elaborate with example?
What do you mean by thread safe?
how to handle exceptions in core applications?