UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is the difference between string, stringbuffer, stringbuilder?

Asked by Last Modified  

22 Answers

Learn Java

Follow 1
Answer

Please enter your answer

Java Trainer

String is immutable, means once you created a String you can not modify, Even if you try to it will create a new string for you and assign that to you. StringBuffer and StringBuilder are immutable, however methods of String buffer are thread safe, So when you are having multithreading in you application...
read more
String is immutable, means once you created a String you can not modify, Even if you try to it will create a new string for you and assign that to you. StringBuffer and StringBuilder are immutable, however methods of String buffer are thread safe, So when you are having multithreading in you application you should use StringBuffer otherwise StringBuilder. read less
Comments

Senior Software Engineer

String is immutable, if you try to alter their values, another object gets created, whereas StringBuffer and StringBuilder are mutable so they can change their values. Thread-Safety Difference: The difference between StringBuffer and StringBuilder is that StringBuffer is thread-safe. So when the...
read more
String is immutable, if you try to alter their values, another object gets created, whereas StringBuffer and StringBuilder are mutable so they can change their values. Thread-Safety Difference: The difference between StringBuffer and StringBuilder is that StringBuffer is thread-safe. 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. Situations: If your string is not going to change use a String class because a String object is immutable. If your string can change (example: lots of logic and operations in the construction of the string) and will only be accessed from a single thread, using a StringBuilder is good enough. If your string can change, and will be accessed from multiple threads, use a StringBuffer because StringBuffer is synchronous so you have thread-safety. read less
Comments

Trainer

String is immutable, i.e. once a String object is created and its value is assigned, its value can not be changed. This is because the String object is stored in Constant String Pool. If you assign a new value to a String reference variable, a new String object is created and stored in Constant String...
read more
String is immutable, i.e. once a String object is created and its value is assigned, its value can not be changed. This is because the String object is stored in Constant String Pool. If you assign a new value to a String reference variable, a new String object is created and stored in Constant String Pool. Alternatively we can use String Buffer and String Builder which are mutable. It means their values can be changed after they have been created as they are stored in heap. The difference between StringBuffer and String Builder are given below: 1) StringBuffer is synchronised whereas StringBuilder is not synchronised 2) StringBuffer is thread safe whereas StringBuilder is not thread safe. 3) StringBuffer is slow in performance whereas StringBuilder is faster. read less
Comments

12 years of MNC company work experience on java ,J2ee technologies

String is immutable and StringBuffer and StringBuilder are mutable. StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously. StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder...
read more
String is immutable and StringBuffer and StringBuilder are mutable. StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously. StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder simultaneously. read less
Comments

5+ years of Experience into Java Development and Training

String ---Immutable --not thread safe StringBuffers---Mutable ---thread safe StringBuilder---Mutable---Not thread safe. Each time you change a string objects value, new object will get created in the memory and reference starts referring the new object. But for StringBuffer and Buider the existing...
read more
String ---Immutable --not thread safe StringBuffers---Mutable ---thread safe StringBuilder---Mutable---Not thread safe. Each time you change a string objects value, new object will get created in the memory and reference starts referring the new object. But for StringBuffer and Buider the existing object will get changed. No new memory gets allocated. read less
Comments

Java Trainer with 6+ years of experience in big MNCs

String eats up the heap memory especially when there are modifications made and hence suggested not to be used in such scenarios.
Comments

Java Web Application Development and Aptitude Trainer

String object are immutable, whereas StringBuffer and String Builder are mutable. Between StringBuffer and StringBuilder, the former is synchronized, hence providing thread safety, while the later is not synchronized, therefore should not be used in case of multithreading.
Comments

Java Tutor

String is an immutable class , whereas StringBuffer is a synchronized mutable class so it is thread safe and StringBuilder is non-synchronized mutable class.
Comments

Software Testing Trainer(Automation)

String does not has append,insert,capacity and replace methods but in StringBuffer and StringBuilder has,String is thread safe since its immutable,StringBuffer is also thread safe since all methods are synchronized but StringBuilder is not thread safe
Comments

Trainer

String is immutable, if you try to alter their values, another object gets created, whereas StringBuffer and StringBuilder are mutable so they can change their values. Thread-Safety Difference: The difference between StringBuffer and StringBuilder is that StringBuffer is thread-safe.
Comments

View 20 more Answers

Related Questions

What are the booming technologies in US from Job point of view
All the terminologies are good. First of all decide your self you want go as functional consultant or technical. If you have java background Learn Hadoop. Billing rate is very high.
Chandra
Why is finally introduced in Java?
Finally is introduced in Java to do the code clean up or if you wants to perform some operation irrespective of whether the code throws an Exception or not.
Agastya
Can Anybody explain Internal code of HashMap?
Now we can synchronize map also by using collections. Synchronize method need to pass map Object as parameter...
Ramakanth
What is the advantage of Java?
Java is object-oriented. This allows you to create modular programs and reusable code. Java is platform-independent. One of the most significant advantages of Java is its ability to move easily from one computer system to another
Kripal
0 0
5
Can a class have interface and vice-versa?
how its possible both has different meaning you cant enclosed it
Deepa
0 0
7

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Introduction to Course Content
Video about what we are going to learn throughout the Java Training Session .

Access Specifiers â?? Private, Protected, Public, Package-private
Access level modifiers determine whether other classes can use a particular field or invoke a particular method. The following table shows the access to members permitted by each modifier. Access...

Lambda Expressions in Java
A lambda expression, introduced in Java 8 is similar to a block of code resembling an anonymous function that can be passed to constructors or methods for execution as an argument. Examples: a)() ->...

Try to clear up the basics, if basics are clear then you can go ahead with any difficult problem
Hey guys, To all the students i just want to convey that just clear up your basics so that they can help you solve anyu problem and you would achieve a great success. Regards, Ishani Chakraborty

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Recommended Articles

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more