public class HelloWorld7 {
public static void main(String[] args) { 
StringBuilder MyStringBuilder = new StringBuilder("Hello World!"); 
MyStringBuilder.Replace(“i”, “?”); 
System.out.print(MyStringBuilder);
}
}

解决方案 »

  1.   

    首先
    StringBuilder MyStringBuilder = new StringBuilder("Hello World!"); //变量名首字母要小写,你这样不规范
    MyStringBuilder.Replace(“i”, “?”); //String类的替换给你找了个参数为char的,因为这个有示例:建议你看一下jdk API文档。public String replace(char oldChar,
                          char newChar)返回一个新的字符串,它是通过用 newChar 替换此字符串中出现的所有 oldChar 得到的。 
    如果 oldChar 在此 String 对象表示的字符序列中没有出现,则返回对此 String 对象的引用。否则,创建一个新的 String 对象,它所表示的字符序列除了所有的 oldChar 都被替换为 newChar 之外,与此 String 对象表示的字符序列相同。 示例: "mesquite in your cellar".replace('e', 'o')
             returns "mosquito in your collar"
     "the war of baronets".replace('r', 'y')
             returns "the way of bayonets"
     "sparring with a purple porpoise".replace('p', 't')
             returns "starring with a turtle tortoise"
     "JonL".replace('q', 'x') returns "JonL" (no change)
     
    参数:
    oldChar - 原字符。
    newChar - 新字符。 
    返回:
    一个从此字符串派生的字符串,它将此字符串中的所有 oldChar 替代为 newChar。
      

  2.   

    public class HelloWorld7{ //方法名首字母也要小写