标签:blog return col dex sub example mil ble 数组
根据开始和结束位置截取字符串:
public String substring(int beginIndex):
"unhappy".substring(2) returns "happy"
"Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)
public String substring(int beginIndex, int endIndex):
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
根据正则表达式截取字符串,返回的可能是字符串数组:
public String[] split(String regex)
Regex | 结果 |
---|---|
: | { "boo", "and", "foo" } |
o | { "b", "", ":and:f" } |
String str[]="boo:and:foo".split(":");
String str[]="boo:and:foo".split("o");
标签:blog return col dex sub example mil ble 数组
原文地址:https://www.cnblogs.com/zxdup/p/12970955.html