java-String-方法

方法:substring();
注意:取到start,前闭后开
greeting = "Hello";
String greetingSubstringstartIndex = greeting.substring(1);//[1...
System.out.println("greetingSubstringstartIndex: "+greetingSubstringstartIndex);
String greetingSubstringstartIndexandendIndex = greeting.substring(2,4);//[2,4)
System.out.println("greetingSubstringstartIndexandendIndex: "+greetingSubstringstartIndexandendIndex);

运行结果:

posted @ 2024-12-13 07:42  基础狗  阅读(10)  评论(0)    收藏  举报