1. In Java, the parameter type of some methods is charsequence, when the parameter that is brought in is actually a string, what is going on?????
A: Charsequence is a string implementation of an interface, rather simple, is the requirement is a string of characters. Therefore, each parameter type is a charsequence method and can actually be used to substitute a string object.
Why don't these methods simply define string as the parameter type? Because there are other classes of charsequence types, such as StringBuffer and StringBuilder, these are important classes. The string object is immutable, and the two are mutable, so we often use StringBuffer and StringBuilder in the process of constructing strings. If those methods define string as parameter types, then it is not possible to use those methods on them, first to convert to string. But StringBuffer and StringBuilder convert to string and then convert it over time, using them instead of just using string "addition" to construct a new string is meant to save time, so if a string is used as the parameter type it is a cup.
2.
Java&android Knowledge points Summary (not regularly updated)