java String

实例一、substring(int beginIndex,int endIndex)

String end ="2007-12-31";
System.out.println(end.substring(8,10));
输出结果:31
下标从0开始数;

参数说明:
beginIndex - 起始索引(包括)。
endIndex - 结束索引(不包括)

相同的方法有:subSequence(int beginIndex,int endIndex);不过使用该方法时需要使 String 类能够实现 CharSequence 接口;

实例二、

concat(String str)将指定的字符串连接到此字符串的结尾;

秀出精彩的自己,让梦飞翔。
原文地址:https://www.cnblogs.com/fangzhizi/p/3886970.html