Well I have two StringBuilder objects, I need to compare them in Java. One way I know I can do is
sb1.toString().equals(sb2.toString());
bu
Since Java 11, StringBuilder implements Comparable, so you can use a compareTo method for the equality test:
StringBuilder
Comparable
compareTo
System.out.println(sb1.compareTo(sb2) == 0);