标签:public code ring world ant length print bst 取字符串
substring() 方法返回字符串的子字符串。
public String substring(int beginIndex)
public String substring(int beginIndex, int endIndex)
子字符串。
String str = "Hello World!";
//截取str子串,从下标为6(包括6)到字符串结束
System.out.println(str.substring(6)); //World!
//截取str子串,从下标为0(包括0)到下标为5(不包括5)
System.out.println(str.substring(0, 5)); //Hello
以下是相当于从头到尾截取字符串 :
String str = "Hello World!";
//Call to ‘substring(0)‘ is redundant(多余的)
System.out.println(str.substring(0)); //Hello World!
//Call to ‘substring(0, str.length())‘ is redundant(多余的)
System.out.println(str.substring(0, str.length())); //Hello World!
标签:public code ring world ant length print bst 取字符串
原文地址:https://www.cnblogs.com/nieaojie625/p/13337967.html