Difference between String and String Buffer?

Answer Posted / sumati

String is immutable
String buffer is mutable

Ex String str = "abc";
str = "new String";
this will creat new memory location and stores "new String"

but in String buffer
StringBuffer strBuf = "abc";
strBuf = "new String"

it will overwrite in same memory location

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are white spaces in java?

525


What are the advantages of java over cpp?

551


What are thread safe functions?

508


Does java support Operator Overloading?

605


Explain where variables are created in memory?

578






How many bits is a string in java?

577


What is a wrapper method?

533


What are the different types of inner classes?

531


Difference between error and exception

5005


What is the new line character?

554


What is the difference between equals() and == in java?

521


Can subclass overriding method declare an exception if parent class method doesn't throw an exception?

502


explain what is transient variable in java?

622


What does system out println () do?

553


Explain the importance of finally block in java?

566