Difference between String and StringBuffer
There are many differences between String and StringBuffer. A list of differences between String and StringBuffer are given below:
Performance Test of String and StringBuffer
Time taken by Concating with String: 578ms Time taken by Concating with StringBuffer: 0ms
String and StringBuffer HashCode Test
As you can see in the program given below, String returns new hashcode value when you concat string but StringBuffer returns same.
Hashcode test of String: 3254818 229541438 Hashcode test of StringBuffer: 118352462 118352462