String常用的方法
来源:互联网 发布:sql update 条件 编辑:程序博客网 时间:2024/05/16 20:31
No.
方法名称
类型
描述
1
public String(char[] value)
构造
将全部字符数组变为字符串
2
public String(char[] value, int offset, int count)
构造
将部分字符数组变为字符串
3
public char charAt(int index)
普通
返回指定索引位置上的字符串,索引从0开始
4
public char[] toCharArray()
普通
将字符串变为字符数组
5
public String(byte[] bytes)
构造
将全部的字节数组变为字符串
6
public String(byte[] bytes, int offset, int length)
构造
将部分字节数组变为字符串
7
public byte[] getBytes()
普通
将字符串变为字节数组,需要传输的时候才会使用
8
public byte[] getBytes(String charsetName)
throws UnsupportedEncodingException
普通
字符串编码转换
9
public boolean equals(String str)
普通
区分大小写的相等比较
10
public boolean equalsIgnoreCase(String anotherString)
普通
不区分大小写的相等的比较
11
public int compareTo(String anotherString)
普通
比较字符串的大小
12
public boolean contains(String s)
普通
判断该字符串是否在总字符串中存在
jdk1.5之后
13
public int indexOf(String str)
普通
从头查找字符串的位置,不存在返回-1
14
public int indexOf(String str, int fromIndex)
普通
从指定位置查找字符串的位置,不存在返回-1
15
public int lastIndexOf(String str)
普通
从尾向前查找字符串的位置,不存在返回-1
16
public int lastIndexOf(String str, int fromIndex)
普通
从指定位置由后向前查找,不存在返回-1
17
public boolean startsWith(String prefix)
普通
判断是否以指定字符串开头
18
public boolean startsWith(String prefix, int toffset)
普通
从指定索引开始,是否以指定字符串开头
19
public boolean endsWith(String suffix)
普通
是否以指定字符串结尾
20
public String substring(int beginIndex)
普通
从指定位置截取到结尾
21
public String substring(int beginIndex, int endIndex)
普通
截取指定位置的字符串
22
public String replaceAll(String regex, String
replacement)
普通
替换全部
23
public String replaceFirst(String regex, String
replacement)
普通
替换首个
24
public String[] split(String regex)
普通
全部拆分
25
public String[] split(String regex, int limit)
普通
拆分为有限个
26
public String concat(String str)
普通
字符串连接,一般使用“+”
27
public String intern()
普通
将内容保存到对象池中
28
public boolean isEmpty()
普通
判断是否为空字符串,但不是null
29
public int length()
普通
取得长度
30
public String toLowerCase()
普通
全部转小写
31
public String toUpperCase()
普通
全部转大写
32
public String trim()
普通
去掉左右空格,但是中间保留
- String的常用方法
- String常用的方法
- String常用的方法
- String常用的方法
- string的常用方法
- String 的常用方法
- String的常用方法
- String 的常用方法
- String的常用方法
- String常用的方法
- String的常用方法
- String常用的方法
- String的常用方法
- String 常用的方法
- String.常用的属性方法
- String类的常用方法
- String类的常用方法
- String中常用的方法
- jquery 动态生成表 绑定click事件,获取同行数据
- Java数据类型和运算符
- HTML Element nodeType 定义
- jdk8,Stream流水线源码解析
- Mycat 源码修改-实现分表规则:按天分表和取摸分表查询
- String常用的方法
- vue.js学习笔记(四)--变化检测问题
- 监听器
- 关于Java,你应该掌握的
- PHP之linux(三) 编辑器(vi/vim) 网络配置
- 像鱼儿离不开水,未来我们将高度依赖机器学习
- HDH 1264 Counting Squares (线段树+扫描线|暴力)
- map使用
- android 自定义 View(1)