定义一个字符串“hello world”将所有的“l”替换成“s”

 /**
 *定义一个字符串“hello world”将所有的“l”替换成“s”。
 
*@author 马涛
 * April 14th,2009
 */
 
 public class Replace
{
 public static void main(String[] args)
 {
  String str = "hello world";
  // 用String 的replace();
  System.out.println(str.replace('l','s'));
 }
}

你可能感兴趣的:(Java,小例子(一些很简单很基础的))