 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Where to use a StringBuffer/StringBuilder than a String in Java?
- The String class objects are immutable whereas the StringBuffer and the StringBuilder objects are mutable.
- A StringBuffer is synchronized while a StringBuilder is not synchronized.
- A Concatenation operator "+" is internally implemented using either StringBuffer or StringBuilder.
- If the Object value is not going to change use String Class because a String object is immutable.
- If the Object value can change and will only be accessed from a single thread, use a StringBuilder because StringBuilder is unsynchronized.
- If the Object value can change and will be modified by multiple threads, use a StringBuffer because StringBuffer is synchronized.
Advertisements
                    