type
status
date
slug
summary
tags
category
icon
password
example-row
example-row
构造方法
public String()
:初始化新创建的String对象,以使其表示空字符序列。
public String(char[] value)
:通过当前参数中的字符数组来构造新的String。
public String(byte[] bytes)
:通过使用平台的默认字符集解码当前参数中的字节数组来构造新的String
判断功能的方法
public boolean equals (Object anObject)
:将此字符串与指定对象进行比较。
public boolean equalsIgnoreCase (String anotherString)
:将此字符串与指定对象进行比较,忽略大小 写。
获取功能的方法
public int length ()
:返回此字符串的长度。
public String concat (String str)
:将指定的字符串连接到该字符串的末尾。
public char charAt (int index)
:返回指定索引处的char
值。
public int indexOf (String str)
:返回指定子字符串第一次出现在该字符串内的索引。
public String substring (int beginIndex)
:返回一个子字符串,从beginIndex开始截取字符串到字符 串结尾。
public String substring (int beginIndex, int endIndex)
:返回一个子字符串,从beginIndex
到endIndex
截取字符串。含beginIndex
,不含endIndex
。例如:s.substring(0, s.length())
转换功能的方法
public char[] toCharArray ()
:将此字符串转换为新的字符数组。
public byte[] getBytes ()
:使用平台的默认字符集将该String
编码转换为新的字节数组。
public String replace (CharSequence target, CharSequence replacement)
:将与target
匹配的字符串使 用replacement
字符串替换。
分割功能的方法
public String[] split(String regex)
:将此字符串按照给定的regex(规则)拆分为字符串数组
- 作者:黄x黄
- 链接:https://hxhowl.site/article/javanote001-string-common
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章