public 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)
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)
Returns a new string that is a substring of this string.
public static void main(String[] args){
String s = "你好我想向你提个问题";
String substr = "";
substr = s.substring(0,6);
System.out.println(substr);
}
}
string a=“你好我想提个问题”
string b=a.substring( 0,4 );
b 是你想要的东西了
楼主其实看看String的API就能查到
嘿嘿,混分啦!!