O'Reilly logo
  • Tom Horn thinks this is interesting:

the authors of StringBuilder did not implement equals(). If you call equals() on two StringBuilder instances, it will check reference equality.


Cover of OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808


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();