当前位置:网站首页>Summary of common methods of string:
Summary of common methods of string:
2022-07-25 22:48:00 【Cool hair】
1. Use charAt() Method can get the character of the position of the index value corresponding to the string , Parameter is int String subscript of type , The return value type is char type .
2. Use compareTo() Method can compare the size of the current string with another string , Parameter is String String of type , The return value type is int type .
3. Use contains() Method can determine whether the current string contains a parameter string , The parameter is an interface type CharSequence, The return value type is boolean type . Return if present true, Returns if it does not exist false.
4. Use equals() Method to compare whether the contents of two strings are the same , Parameter is Object class , That is, you can pass any type of parameter , The return value type is boolean type , If the contents are equal, return true, Unequal return false.
5. Use equalsIgnoreCase() The method is to ignore case ( English letter ) Comparison , Parameter is String type , The return value is boolean type . After ignoring case , If the contents are equal, return true, Unequal return false.
6. Use startsWith() and endsWith() Method can determine whether the atomic character string starts or ends with the parameter string , Parameter is String type , The return value is boolean type , If it starts with a parameter string, it returns true, Otherwise return to false.
7. Use indexOf() Method can find the position where the parameter string first appears , The return value is int type , If it exists, the subscript position of the first occurrence of the string is returned , Otherwise return to -1.
8. Use lastIndexOf() Method can find the position of the last occurrence of the parameter string , The return value is int type , If it exists, it returns the subscript of the last occurrence of the string , Otherwise return to -1.
9. Use length() Method can get the length of the current string , The return value is int type .
10. Use replace() Method can replace string , The return value is String type .
11. Use split() Method to split a string , Parameter is String type , The return value is String[] Array
12. Use substring() Method intercepts the string , Parameter is int type , The return value is String type
13. Use toCharArray() Method converts the current string into an array of character types , The return value is char[] Type array
14. Use toLowerCase() or toUpperCase() Convert all letters to lowercase or uppercase , The return value is String type
15. Use trim() You can remove the first and last white space characters of the string , Include \t,\r,\n, The return value is String type
16. Use format() Format array output , Pass in the parameter , Replace placeholders , Generate a new string , The return value is String type
17. Use join() Method is used to splice strings , The return value is String type
18. Use valueOf() Method can convert any reference type or basic type to string type , The return value is String type
边栏推荐
- 为啥谷歌的内部工具不适合你?
- Multi data source switching
- 武汉理工大学第三届程序设计竞赛 B-拯救DAG王国(拓扑性质处理可达性统计问题)
- [training Day11] Calc [mathematics]
- We media people must have four resource tools, each of which is very practical
- (1) Integrating two mapping frameworks of Dao
- Why is Google's internal tools not suitable for you?
- 2020-09-17
- 【集训DAY11】Calc【数学】
- IFLYTEK smart office book air e-book reader makes my work life healthier
猜你喜欢

(1) Integrating two mapping frameworks of Dao
![[training day13] backpack [dynamic planning] [greed]](/img/a7/3df395d84f510dea8b42ebcc4ff5f2.png)
[training day13] backpack [dynamic planning] [greed]

QT的Tree View Model示例

Day006 select structure (if statement exercise)

Simple setting method of search box

Share two music playing addresses

编译器引论

Hcie is finally in hand, and the road begins

Matrixcube unveils the complete distributed storage system matrixkv implemented in 102-300 lines

分享两个音乐播放地址
随机推荐
The third programming competition of Wuhan University of technology b- save the kingdom of DAG (topological properties deal with accessibility Statistics)
Summary 1 - deep learning - basic knowledge learning
Mysql数据类型
Simple application of partial labels and selectors
Force deduction solution summary 919 complete binary tree inserter
ECMA 262 12 Lexical Grammer
CSV intro
Multi data source switching
【集训DAY11】Calc【数学】
Vodak software: Smart City solution
TFrecord写入与读取
[training day13] backpack [dynamic planning] [greed]
We media people must have four resource tools, each of which is very practical
QT的Tree View Model示例
Two methods of printing strings in reverse order in C language
编译器引论
Opencv compile and call GPU version
Oracle query statement summary
Simple setting of drop-down triangle
Why should we launch getaverse?