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

Which is best to build web applications: PHP, Python, or Ruby? Why?
I have used almost all of the three language in my web working experience.PHP:It may be not that cool and I think it doesn't rely too much on the framework. Yes, PHP is just a language, but it is the only...
Sunil
0 0
7
What is a constructor in Java?
Constructor is a special method to initialise Java objects. Usually initialisation logic is kept inside the constructor. Java compiler by default creates a default no arg constructor if no constructor is defined already.
Rishu
0 0
5

What is meant by Java full stack and angular Java?

Fullstack development means the combination of UI technologies (client-side) + Backend technology (server-side). UI technology like Angular or ReactJs (Front end technologies). It's all about client-side...
Anuradha
why string class is override in euals()/ hashCode Hethods?
Equals method and hash code methods compare two objects based the memory location occupied by objects. Two different objects always occupy two different locations in heap memory. So equals and hashCode...
Rami Reddy
I need to know about JDBC. Can you help me please?
JDBC is an api, which is used to connect Java program to database.
Ganesh

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

Ask a Question

Related Lessons

CONDITIONAL STATEMENT - IF ELSE
1. IF condition only if is true conditon is required. if(condition){//statements} 2. IF-ELSE condition 1. to check whether the condition will be true or false.syntax of if-else2. only 1 conditionif(condition){//statements}else{//statements} 3....

Big Data Hadoop Training
What is Big Data? Big data means really a big data, it is a collection of large datasets that cannot be processed using traditional computing techniques. Big data is not merely a data, rather it has become...

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

What Is Applet & Its Life Cycle?
What is Applet & its life cycle?Applet is a Java programme that can be embedded into HTML page.Java Applet runs on the java enables web browsers such as Mozilla & Internet Explorer.Applets are...
I

ICreative Solution

0 0
0

Android : Support multiple themes in an android application
If you are developing a theme based application to enhance user experience, then following steps needs to follow.We are taking example of an android application having 2 themes white and black.Step 1:Define...

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