String str = "我爱 Java 编程"; String result = str.substring(3); System.out.println(result); // 输出:Java 编程
public static void main(String[] args) { String day = "Today is Monday"; //原始字符串 System.out.println("substring(0)结果:"+day.substring(0)); System.out.println("substring(2)结果:"+day.substring(2)); System.out.println("substring(10)结果:"+day.substring(10)); System.out.println("substring(2,10)结果:"+day.substring(2,10)); System.out.println("substring(0,5)结果:"+day.substring(0,5)); }输出结果如下所示:
substring(0)结果:Today is Monday substring(2)结果:day is Monday substring(10)结果:onday substring(2,10)结果:day is M substring(0,5)结果:Today
Copyright © 广州京杭网络科技有限公司 2005-2024 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有