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

What is ART?

junior

Explain Android notification system

senior

What are best practices for storing and protecting private API keys in applications?

Bình luận

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

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