what is stringBuffer and StringBuilder?
Answers were Sorted based on User's Feedback
Answer / anonymous
String is immutable whereas StringBuffer and StringBuilder
can change their values.
The only difference between StringBuffer and StringBuilder
is that StringBuilder is unsynchronized whereas
StringBuffer is synchronized. So when the application needs
to be run only in a single thread then it is better to use
StringBuilder. StringBuilder is more efficient than
StringBuffer.
Criteria to choose among String, StringBuffer and
StringBuilder
If your text is not going to change use a string Class
because a String object is immutable.
If your text can change and will only be accessed from a
single thread, use a StringBuilder because StringBuilder is
unsynchronized.
If your text can changes, and will be accessed from
multiple threads, use a StringBuffer because StringBuffer
is synchronous.
| Is This Answer Correct ? | 26 Yes | 0 No |
Answer / modi[achir communication]
All methods in StringBuffer class are Synchronized whereas
in StringBuilder class methods are not synchronized.
StringBuilder is faster than StringBuffer because of the
synchronized method in StringBuffer.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / srinu
StringBuffer:-
1)All methods in String Buffer class are Synchronized.
2)Performance is slow because these are synchronized.
StringBuilder:-
1)StringBuilder class methods are not synchronized.
2)performance is faster.
| Is This Answer Correct ? | 2 Yes | 0 No |
If we opened windows notepad 4 times, does it starts 4 processes or 4 threads?
How substring() method of string class create memory leaks?
what is the RMI / IIOP?
What is permgen or permanent generation?
What is synchronization and why is it important?
whats is mean by object and class?
How to send a request to garbage collector?
What is the difference between Process and Threads?
Java is fully object oriented languages or not?
For an example, if we have some variable in run method, and we created one or more threads. Does all threads will share the same variable or a copy of variable is created for each thread??
How will you pass parameters in RMI? Why do you serialize?
What is Servlet Filter And What does it work?