Câu hỏi phỏng vấn Android
Câu hỏi

Explain String vs StringBuilder vs SpannedString vs SpannableString vs SpannableStringBuilder vs
CharSequence ?

Câu trả lời

Here is a concise explanation of the differences between String, StringBuilder, SpannedString, SpannableString, SpannableStringBuilder, and CharSequence in Android:

A String is immutable, meaning the text cannot be changed once created. It also does not have any spans (formatting information like bold, italic, etc.) associated with it. Use a String when the text does not need to be changed and does not require any styling[1][3].

A StringBuilder has mutable text, allowing you to modify it without creating a new object. However, it does not have any span information - it is just plain text. Use a StringBuilder when you need to change the text, but do not need to style it[1][3].

A SpannedString has immutable text (like a String) and immutable span information. It is a concrete implementation of the Spanned interface. Use a SpannedString when your text has style but you do not need to change either the text or the style after creation[1][3].

A SpannableString has immutable text, but its span information is mutable. It is a concrete implementation of the Spannable interface. Use a SpannableString when your text does not need to be changed but the styling does[1][3].

A `SpannableStringBuilde...

middle

middle

Gợi ý câu hỏi phỏng vấn

middle

When to use Android Loaders?

expert

What is the difference between Local , Normal , Ordered and Sticky broadcasts?

senior

How to avoid reverse engineering of an APK file?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào