Get 50% Discount on Our Udemy Course to Memorize the Periodic Table in 30 minutes Click Here. COUPON CODE: ALCHEMY

How to remember difference between StringBuilder and StringBuffer?

0 votes
asked Dec 15, 2015 by nanospeck (6,920 points)

How can I remember about thread safety in StringBuilder and StringBuffer without getting confused with each other.




1 Answer

0 votes
answered Dec 15, 2015 by nanospeck (6,920 points)
Here is an easy trick to remember it.

Only StringBuilder has the letter 'i' in it . If you put the letter 'i' upside down, it becomes '!' - equivalent to 'not' symbol in programming languages.

Hence 'StringBuilder' can be related with the word 'not' which can help you remember -> non-synchronized.