Difference between String and StringBufferThere are many differences between String and StringBuffer. A list of differences between String and StringBuffer are given below:
Performance Test of String and StringBufferConcatTest.java Output: Time taken by Concating with String: 578ms Time taken by Concating with StringBuffer: 0ms The above code, calculates the time required for concatenating a string using the String class and StringBuffer class. String and StringBuffer HashCode TestAs we can see in the program given below, String returns new hashcode while performing concatenation but the StringBuffer class returns same hashcode. InstanceTest.java Output: Hashcode test of String: 3254818 229541438 Hashcode test of StringBuffer: 118352462 118352462 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India