Java substring() method: evaluate substring (intercept string)

Grammar 1

substring(int beginIndex)

Example

String strCom = "I Like Java";
String strResult = strCom.substring(3);

Grammar 2

substring(int beginIndex)

Typical application

public static void main(String[] args){
    String str="Hello Word";  //定义字符串
    String substr=str.substring(3); //截取字符串
    System.out.println("原字符串是:"+str); //输出原字符串
    System.out.println("截取后的字符串为:"+substr); //输出截取后的字符串
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>