the authors of
StringBuilder did not implement
equals(). If you call
equals() on two
StringBuilder instances, it will check reference equality.
- Chapter 3: Core Java APIs
- from OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808
- Publisher: Sybex
- Released: December 2014
Which means that when you have two references which both point to the same SB string they won't return as equal, but when you convert them to strings, those strings will be equal.
StringBuilder a = new StringBuilder("hohum");
StringBuilder b = new StringBuilder("hohum");
String aS = a.toString();
String bS = b.toString();
Share this highlighthttp://www.safaribooksonline.com/a/oca-oracle-certified/4234951/