What is Android TextUtils used for?

I was wondering: "Why do others use TextUtils for many purposes?" - but I do not quite understand about it. The developer's site says it's a simple line break. I understand this, but I don’t know how to use it in a practical manner or for what purposes can I use it? Can someone give me some practical example code snippet?

+6
source share
2 answers

This is just a set of utility functions for performing operations on String objects. In fact, the entire class has no instance fields or methods. Everything is static. Consider it as a container for grouping functions with text semantics. Many of them could be methods of the inherited String class or the CharSequence class. For example, you can:

TextUtils.indexOf(string, char) 

doing the same thing

 string.indexOf(char); 

Many of them do what you can already do using string public methods. Many others add extra features. This class serves at the method level for the same purpose as the package at the class level.

+9
source

one of the uses of textUtils , for example, allows you to say that you have the string "apple,banana,orange,pinapple,mango" that does not fit into the specified width, it can be converted to "Apple, banana, 2 more" .

+10
source

Source: https://habr.com/ru/post/949887/


All Articles