1.substring():返回字符串的子字符串。
下面展示一些 内联代码片
。
public String substring(int beginIndex)或
public String substring(int beginIndex, int endIndex)
beginIndex -- 起始索引(包括),索引从 0 开始。
endIndex -- 结束索引(不包括)。
2.charAt():返回指定索引处的字符。索引范围为从 0 到 length() - 1。
public class Test {
public static void main(String args[]) {
String s = "www.runoob.com";
char result = s.charAt(6);
System.out.println(result);
}
}
//结果为n
3.toCharArray() :将字符串转换为字符数组