While trying to comprehend this answer, I failed to understand the difference between StringBuilder
and Editable
. This image (minus the hand-drawn red circles) comes from that answer.
Both of them have methods to append
, delete
, insert
, and replace
text. I see that StringBuilder
is an actual class while Editable
is an interface. But I can get an Editable
back from a TextView
with textView.getEditableText()
, which seems strange if it is an interface. What is the concrete implementation behind the scenes? I also see that Editable
can have spans while a StringBuilder
doesn't.
I think I am close to understanding the difference, but I could use a little more explanation. I was surprised that I couldn't find where this question had already been asked, so I am asking it now.
Again, specifically:
- What is the difference between
StringBuilder
andEditable
? - When should I use one as opposed to the other?