The Artima Developer Community
Sponsored Link

Java Buzz Forum
Difference between StringBuilder and StringBuffer in Java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
Difference between StringBuilder and StringBuffer in Java Posted: May 20, 2014 8:57 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: Difference between StringBuilder and StringBuffer in Java
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
If you are in hurry and heading straight to interview then I won't take much of your time, In couple of words, main difference between StringBuffer and StringBuilder is between four parameters, synchronization, speed, thread-safety and availability. StringBuffer is synchronized and that's why thread-safe, but StringBuilder is not synchronized, not thread-safe and that's why fast. Regarding availability, StringBuffer is available from Java 1.0 while StringBuilder was added on Java 5. Now we can take a breath, and can continue with rest of this article. In Java, there are three classes to deal with String data type, String, StringBuffer and StringBuilder. All of three belongs to java.lang package, which is automatically imported to every Java program thus you don't need to do any import for using StringBuilder and StringBuffer. Out of these three, String is immutable in Java, while StringBuilder and StringBuffer are mutable version of String. Some one with little bit of common sense will think that, why do one need three classes for same functionality, why can't String just do what StringBuilder and StringBuffer does. This definitely would have required keeping String mutable, which is not favourable to Java designers for many reasons, like Security, String Pool, and Performance. So designers of Java API has introduced a pattern of providing a mutable companion class for immutable main class. StringBuffer was introduced along with String from very first version of Java API, the JDK 1.0, while StringBuilder was introduce quite late in early 2000s when Java 1.5 was released.
Read more ยป

Read: Difference between StringBuilder and StringBuffer in Java

Topic: One now, two later: Groovy updates add Java 8 support Previous Topic   Next Topic Topic: Too Fast, Too Megamorphic: what influences method call performance in Java?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use