本帖最后由 pzfpang449 于 2013-1-24 13:41 编辑
String begin = "1000-06-01";
String end = "1000-06-30";
begin = begin + end;
end = begin.substring(10);//end ="1000-06-01"
begin = begin.substring(0,10);//begin = "1000-06-30"
用String java.lang.String.substring(int beginIndex, intendIndex);
来截取字符串来达到互换的目的
Java代码
public void method1(){
String a = "字符串a" ;
String b = "字符串b" ;
a = a + b;
b = a.substring(0,(a.length()-b.length()));
a = a.substring(a.length()-b.length(),a.length());//主要此时b.length()时转换前a的长度
System.out.println("a:"+a);
System.out.println("b:"+b);
} |