StringBuffer and StringBuilder in Java
Core difference between StringBufferand StringBuilder in Java :
StringBuffer:
- Thread safe
- Synchronized
- Slow than StringBuilder
StringBuilder
- Not thread safe
- Not-Synchronized
- Faster than StringBuffer
1) The String object is immutable in Java but StringBuffer and StringBuilder are mutable objects.
2) StringBuffer is synchronizedwhile StringBuilder is not which makes StringBuilder faster than StringBuffer.
post a comment