what is difference between String buffer and String builder?

Answer Posted / rajujohn

hi All
Both are mutable ,that means we can change value of the
instance variable using append,insert and ...
But only one difference when you go for the multi-thread
concept you use StringBuffer,Because it is thread safe ,that
means, if one thread access this stringbuffer variable on
the time another thread cant access this stringbuffer,so
stringbuffer is slowest performance compare to stringbuilder.

by raju.j

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by synchronized non access modifier?

758


Can subclass overriding method declare an exception if parent class method doesn't throw an exception?

746


Can we call a non-static method from inside a static method?

777


Explain about version control?

773


Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.

1814


When the constructor of a class is invoked?

773


what are the states associated in the thread? : Java thread

829


Can I declare a class as private?

814


What are the advantages of java over cpp?

806


How do you differentiate abstract class from interface?

734


What are three types of loops in java?

800


What is the difference between multitasking and multithreading in Java

963


What is thread life cycle?

717


What is encapsulation in java?

847


When is finally block not called?

816