java的string类(String class of Java)

public class Test {
public static void main(String[] args) {
//构造方法创建字符串
String s1 = new String(“hello”);
char[] chars = {‘a’,’b’,’c’};
//常用方法
//length获取字符长度
s1.length();
//indexOf查询指定字符的位置
s1.indexOf(‘l’);
//substring 左闭右开
s1.substring(9);
//charAt获取指定位置字符
s1.charAt(1);
//concat字符串拼接,返回一个新字符串
s1.concat(“abc”);
//startsWith 判断字符串是不是已什么字符串开始
//contains判断字符串是不是包含
//isEmpty判断字符串是不是空字符串
//toUpperCase将字符串变成大写
//replace替换
//toCharArray将字符串转化成字符数组
s1.toCharArray();
s1.getBytes();

}

}

————————

public class Test {
public static void main(String[] args) {
//Construct method to create string
String s1 = new String(“hello”);
char[] chars = {‘a’,’b’,’c’};
//Common methods
//Length gets the character length
s1. length();
//Indexof queries the position of the specified character
s1. indexOf(‘l’);
//Substring left closed right open
s1. substring(9);
//Charat gets the character at the specified position
s1. charAt(1);
//Concat string splicing to return a new string
s1. concat(“abc”);
//Startswith determines whether a string has started with a string
//Contains determines whether the string contains
//Isempty determines whether the string is an empty string
//Touppercase turns the string to uppercase
//Replace replace
//Tochararray converts a string into a character array
s1. toCharArray();
s1. getBytes();

}

}