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

simple way to explane the servlet in java
Servlet is a program wich executed in server and assists in responding to client queries..... Usually confidential tasks are done by using servlets or other server side codes
Anish
What is Service Locator in java?
The Service Locator abstracts the API lookup (naming) services, vendor dependencies, lookup complexities, and business object creation. Provides a simple interface to clients. This reduces the client's...
Arunava Chatterjee
What are the benefits of online training / e-training when compared to traditional contact training?
First of all, online training saves the time, money and energy of both student as well as teacher which is required for travelling. Online training can be conducted from any part of the world and I have...
Sadhu Sreenivasa Rao
What are the necessary qualifications needed for a Java tutor?
1. Knowledge 2. Good education background 3. Experience in teaching 4. Applications and projects that he has himself worked on 5. The zeal to help students
Darshan
0 0
7
Which programming language should one use for large scale machine learning, Java or C++?
Java but preferred language now is R or Scala or Python .
Rayaan
0 0
5

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

Ask a Question

Related Lessons

Implementation: What Is JPA And JPA?
The basic Java framework to access the database is JDBC. Unfortunately, with JDBC, a lot of hand work is needed to convert a database query result into Java classes. JPA allows us to work with Java classes...


Java complete reference-herbert schildt
Sample program: class Sample { public static void main(String args ) { System.out.println("Sample") ; } } Program explanation: Keyword used in line 1- class The name...

JAVA OOPs Concepts (Object-Oriented Programming System)
JAVA OOPs Concepts (Object-Oriented Programming System) It is primarily having below crucial points. Without below essential points, we will never be able to achieve OOPs in java, PHP, C#, etc. Now let...

How can everyone prepare to clear any Java interview?
Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview...

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