1.
String a = "string";
int index = a.indexOf("tri");
a = a.substring(index, index + "tri".length());
删除的话可以用
a = a.substring(0,index) + a.substring(index+"tri".length());2.
StringTokenizer st = new StringTokenizer("test string"," ");
while(st.hasNextToken()) {
System.out.println(st.nextToken());
}3.
http://java.sun.com
String a = "string";
int index = a.indexOf("tri");
a = a.substring(index, index + "tri".length());
删除的话可以用
a = a.substring(0,index) + a.substring(index+"tri".length());2.
StringTokenizer st = new StringTokenizer("test string"," ");
while(st.hasNextToken()) {
System.out.println(st.nextToken());
}3.
http://java.sun.com
s = s.substring(1,4);
2. 同1, 用substring方法.
这是用法:
substringpublic String substring(int beginIndex)
Returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.Examples:
"unhappy".substring(2) returns "happy"
"Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)
Parameters:beginIndex - the beginning index, inclusive.Returns:the specified substring.Throws:IndexOutOfBoundsException - if beginIndex is negative or larger than the length of this String object.