public String(char[ ] value) :
String类的构造方法,用于将字符数组转换为一个字符串。
pubic String(char[ ] value,int offset,int length) :
String类的构造方法,将字符数组value从下标offset开始,长度为length的
范围的字符转换为字符串。
public String(byte[ ] bytes) :
String类的构造方法,将字节数组转换为一个字符串。
public String(byte[ ] bytes , int offset , int length) :
String类的构造方法,将字节数组bytes从下标offset开始,长度为length的
范围的字节转换为字符串。
public static String valueOf(char[ ] arr) :
String类内的静态方法,底层通过调用构造方法,将字符数组转换为一个
字符串,声明为静态方法,通过类名直接调用更方便。
public static String valueOf(char[ ] arr , int offset , int length) :
String类内的静态方法,底层通过调用构造方法,将范围内的字符数组转换
为一个字符串,声明为静态方法,通过类名直接调用更方便。
pulic char[ ] toCharArray( ) :
将字符串转换为一个字符数组。
public char charAt(int index) :
得到指定下标位置的单个字符。
public byte[ ] getBytes( ) :
将字符串转换为一个字符数组。
1.2 获取方法
public int indexOf(char ch) :
得到指定字符的下标位置,没有返回-1。
public int indexOf(char ch , int fromIndex) :
从指定下标位置fromIndex开始查找,得到指定字符的下标位置。
public int indexOf(String str) :
得到指定字符串出现的位置,第一次出现的位置。
public int IndexOf(String str , int fromIndex) :
从指定下标位置fromIndex开始查找,得到指定字符串第一次出现的位置。
public int lastIndexOf(char ch) :
得到指定字符最后一次出现的位置。
public int lastIndexOf(char ch , int fromIndex) :
从指定下标位置fromIndex开始往前查找,得到指定字符的下标位置。
public int lastIndexOf(String str) :
得到指定字符串的最后一次出现的位置。
public int lastIndexOf(String str , int fromIndex) :
从指定下标位置开始往前找,得到指定字符串出现的下标位置。
1.3 判断方法
public boolean endsWith(String str) :
判断是否以指定字符串结尾。
public boolean isEmpty( ) :
判断是否是空字符串。
public boolean equals(Obejct obj) :
用于比较字符串的内容,区分大小写。
public boolean equalsIgnoreCase(String strj) :
字符串比较内容,且不区分大小写。
public boolean contains(String str) :
判断当前字符串是否包含指定字符串。
1.4 其它方法
public String replace(char oldChar , char newChar) :
用新字符替换掉字符串中的旧字符,全部替换,返回一个新的字符串。
public String[ ] split(String regex) :
将字符串按照regex为分隔符,拆分为一个字符串数组。
public String[ ] split(String regex , int limit) :
将字符串按照regex为分隔符,limit为拆分后的字符串个数,得到一个字符
串数组。
public String substring(int beginIndex) :
从指定的下标位置开始截取字符串,到末尾。
public String substring(int beginIndex , int endIndex) :
从指定的下标位置beginIndex截取字符串到endIndex - 1 ,要头不要尾。
public String toUpperCase( ) :
转大写。
public String toLowerCase( ) :
转小写。
public String trim( ) :
去除字符串的前后空格。