Home Answers Viewqa Java-Beginners explain the difference between string builder and string buffer classes

 
 


Parvathambal
explain the difference between string builder and string buffer classes
1 Answer(s)      a year and a month ago
Posted in : Java Beginners

Hi,

Here is my code

public static void main(String[] args) {

String s1 = "abc"; StringBuffer s2 = new StringBuffer(s1); StringBuffer s3
= s2; StringBuffer s4 = new StringBuffer(s1);

}

in this example how many objects are created ?

could you please explain.

View Answers

April 13, 2012 at 12:22 PM


The only difference between StringBuffer and StringBuilder is that StringBuilder is unsynchronized whereas StringBuffer is synchronized. 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.

For more information, visit the following link:

http://www.roseindia.net/java/java-tips/data/strings/23stringbufferetc.shtml









Related Pages:
explain the difference between string builder and string buffer classes
explain the difference between string builder and string buffer classes  Hi, Here is my code public static void main(String[] args) { String s1... ? could you please explain
(ii) String and String Buffer Class
(ii) String and String Buffer Class  difference between String and String Buffer Class
(ii) String and String Buffer Class
String and String Buffer Class  difference between String and String... between String and StringBuffer 1) String object is immutable... whereas String buffer objects are not constants but growable
Java string buffer
Java string buffer  What is the basic difference between string and stringbuffer object
Differences between the String, StringBuilder, and StringBuffer classes
Differences between the String, StringBuilder, and StringBuffer classes StringBuffer versus String Java provides the StringBuffer and String classes.... The significant performance difference between these two classes is that StringBuffer
(ii) String and String Buffer Class
String and String Buffer Class  differences between : String and String Buffer Class
String and StringBuffer - Java Beginners
performance difference between these two classes is that StringBuffer is faster...; Hi vijay Java provides the StringBuffer and String classes... buffer implements a mutable sequence of characters. A string buffer is like
string
string  String helloString = new String(helloArray); System.out.println(helloString); i am unable to understand this. could u plz explain
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both ,in java which one is legal   The only difference is style, where
String
String  how to print in between numbers if the question "String s = "1,2,3,4,5,6,8,-25"" out must be 1 2,3,4,5,6,7,8,9,10,upto25
Difference between translate and replace
Difference between translate and replace   hiii, What is the difference between translate and replace?   hello, Replace replace every instence of character with character sting by the given charator of string
Difference between GET and POST
Difference between GET and POST   Difference between GET and POST ?   The difference between a GET and a POST is the way data... string in the URL. For example, if you had a form with a field named 'para1
Java string buffer
Java string buffer  what is stringBuffer and StringBuilder
what is the difference between jdk 1.4 and 1.5 and 1.6
what is the difference between jdk 1.4 and 1.5 and 1.6  what is the difference between jdk 1.4 and 1.5 and 1.6   Java 1.4 Features... constructs such as classes and methods to be tagged with additional data, which
String Ques
String Ques  what is difference between String str="abc"; and String str=new String("abc");   Hello Friend, Differences: 1)String str=new string("abc") creates two objects, one in heap memory and one in string
Explain the persistence class in hibernate?
Explain the persistence class in hibernate?  What is persistence class in hibernate?   Persistence class are simple POJO classes...; @Column(name = "name") private String name; @Column(name = "salary
classes
classes  differnce between class and object   please say exact difference between class and object   please say exact difference between class and object   please say exact difference between class
What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Difference: 1... typed). Ex : Variables in Java: int num;String st; Variables
difference
difference  difference between Method Overloading and method Overriding   Difference between Method Overloading and Method Overriding... in different classes. one in the super class can be made virtual and other can override
String doubts - Java Interview Questions
String doubts  difference between String and StringBuffer
Hi .Difference between two Dates - Java Beginners
Hi .Difference between two Dates  Hi Friend.... Thanks for ur Very good response.. Can u plz guide me the following Program.... difference... static void main(String args[]){ DateDifference difference = new
Difference between Java IO Class - Java Beginners
Difference between Java IO Class  What is the difference in function between Two set of Stream class as mention below- 1)FileInputStream... a string containing a path name or a File object. 3. You can also specify whether
To get the String between two strings
To get the String between two strings  How to get string between two strings repeatedly using java?   Hi, Please tell me more about what do you want to achive. Thanks
difference between applet and swings
difference between applet and swings  what are the major difference between swing and applets   Hello Friend, Differences: 1) AWT stands... Foundation classes). 2) AWT components use native methods Swing components use
Difference between jsonstring and json object
Difference between jsonstring and json object  Is There any difference between JsonString and jsonobjectA? if there is any differece could any one explain with example. Thanks venkatesh
Difference between Normal Insert and BLOB insert
Difference between Normal Insert and BLOB insert  I have sql database.... So what is the difference?? and what changes i have to make in order to runn... types for different fields, varchar for string, bigint for integer, blob for image
javascript string - Java Beginners
significant difference between them that I should be aware...javascript string  what is the differenece between ' and " in javascript.   Hi!Friend. here is your answer
Builder Pattern
difference between these two patterns is that Builder pattern makes a complex object... Builder Pattern       Builder Pattern: This design pattern allows the client
Difference between == and equals method in java
Description: For comparing equality of string ,We Use equals() Method... value of string object whereas equals() method is present in the java.lang.Object class. This method compares content of the string object. . Code
Jdbc Mysql Connection String
JDBC Mysql Connection String       In this Tutorial we want to explain you a code that makes you to understand JDBC MysqlConnection String. The code include a class 
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme
String
String  how to add spaces with string functions.?   Hi... String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n) { return
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
Java code for buffer operation...!!!
Java code for buffer operation...!!!  Implement a buffer operation... BufferOperation { public static void main(String[] args) { StringBuffer buffer=new StringBuffer(); Scanner input=new Scanner(System.in
String
characters in string?   import java.util.*; class RemoveDuplicateCharatcersFromString { public static String removeDuplicates(String s... < s.length(); i++) { String st = s.substring(i, i + 1
String
String  write down the code of remove any character from a given string without using any string function   please give me the code of remove any given character from a given string without using function
string
ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine(); String str[]=st.split(" "); for(int i=0
string
string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String capitalizeFirstLetter( String str ) { final StringTokenizer st = new StringTokenizer( str
string
string   just i want to a program in a short form to the given string in buffered reader for example input string: Suresh Chandra Gupta output: S. C...; public class StringTest { public static void main(String [] args
string
string  write a program to accept the string and store the reverse stream into another array and print
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  write a program using string it should replace 'c'char to integer number as 1 in whole source
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
intern() of String
intern() of String  Please explain me the working of intern().   Hello Friend, You can compare String objects and string characters... information, visit the following link: String intern() method Thanks
string
and also displaying that contain word? Like I want to find "a" in the string... and a character. It then count the occurrence of that character in the string and display... String_Example { public static void main(String[] args
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
Pattern,Matcher,Formatter and Scanner classes
to understand the difference between the greedy quantifier (the first test...; Table 3.2. Difference between quantifiers/font>.... The format() method is static in the String class. In addition, classes PrintStream
how to get string between two characters
how to get string between two characters  hgow to get string from between two characters. ex:hareesh.arava@gmail.com from the above word i want a string between characters . and @ send the required method and give better example
string
string  a java program using string function that computes your initials from your full name and display them   Please visit the following links: http://www.roseindia.net/tutorial/java/core/printInitials.html http

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.