1.String类和StringBuffer类 它们都是处理字符串的类,但是它们有一个最大的区别,那就是。eg1: ...... //omit some code String s1= You are hired! ; System.out.println(s1.replace(′h′,′f′));//用f把字串中的h替换了 System.out.println(s1); ...... //omit some code 运行结果: You are fired! You are hired! 结果分析: 从结果,明显可知,s1的值并没有被改变,而第一行结果只是屏幕内容的替换. eg2: ...... //omit some code StringBuffer s2=new StringBuffer( Hello from Java! ); s2.replace(6,10, to ); System.out.println(s2); ...... //omit some code 运行结果: Hell...
查看详细内容 >>