What is the difference between String, String Builder, and Buffer?
S.no | String | StringBuffer | StringBuilder |
---|---|---|---|
1. | Immutable | Mutable | Mutable |
2. | For logic operations, it is slow | Thread-safe | Faster and more efficient |
3. | Use it when immutable structure is required. | Use it for creating mutable character sequence but string changes must be synchronized | Use it for creating mutable character sequence |
BY Best Interview Question ON 29 Mar 2020