compare « StringBuilder « Java Data Type Q&A





1. In java how would you compare two StringBuilders and copy only the difference of the two, into one    stackoverflow.com

In java is there any elegant way to compare two different StringBuilders and copy only the difference of the two, into one?

Sb1 = "Hello World"
Sb2 = "Hello World says the ...

2. Effective value comparison of StringBuilder objects    forums.oracle.com

Why not just sb.equals(sb1)? As far as comparing two strings with equals() vs contentEquals() is concerned there is nothing in the documented API that suggests any difference "from a performance perspective". And it would seem a bit weird if they did something different (or differently) when comparing two strings. The StringBuilder documentation does say that StringBulder's toString() creates a new String ...