Kazekage Gaara
Kazekage Gaara

Reputation: 15052

What is the purpose of making Editable as return type of EditText.getText() method?

As per the API, the getText() method of EditText returns Editable. What was the purpose of it? It could simply have been a String return type?

And as per the Editable API:

This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings).

To achieve immutable functionality, why not use StringBuilder or StringBuffer instead?

Upvotes: 1

Views: 115

Answers (1)

Sam
Sam

Reputation: 86948

public interface Editable implements GetChars, Spannable, Appendable, CharSequence

Amoung other features, Editable retains Spannable data which Strings and StringBuilders cannot do.

Upvotes: 5

Related Questions