首页上一页 1  下一页尾页 3 条记录 1/1页
        <>P130页有错误! 
                 	
                        发表在Java图书答疑
                        2009-07-12                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                           <<JAVA程序设计标准教程>>
P130面最上方
String str="公司地址:明日科技";
str=str.replace("地址","名称"); //替换字符串内容
System.out.println(str);
通过在eclipse中运行
public class replacestring {
public static void main(String[] args) {
String str="公司地址:明日科技";
str=str.replace("地址","名称");
System.out.println(str);
}
}
出现
java.lang.Error: 无法解析的编译问题:
类型 String 中的方法 replace(char, char)对于参数(String, String)不适用
at replacestring.main(replacestring.java:5)
Exception in thread "main"
将此改成
public class replacestring {
public static void main(String[] args) {
String str="公司地址:明日科技";
str=str.replace('地','名');
str=str.replace('址','称');
System.out.println(str);
}
}
运行结果:公司名称:明日科技 (正常)
请老师解答一下!谢谢
                
        	
        
        
    P130面最上方
String str="公司地址:明日科技";
str=str.replace("地址","名称"); //替换字符串内容
System.out.println(str);
通过在eclipse中运行
public class replacestring {
public static void main(String[] args) {
String str="公司地址:明日科技";
str=str.replace("地址","名称");
System.out.println(str);
}
}
出现
java.lang.Error: 无法解析的编译问题:
类型 String 中的方法 replace(char, char)对于参数(String, String)不适用
at replacestring.main(replacestring.java:5)
Exception in thread "main"
将此改成
public class replacestring {
public static void main(String[] args) {
String str="公司地址:明日科技";
str=str.replace('地','名');
str=str.replace('址','称');
System.out.println(str);
}
}
运行结果:公司名称:明日科技 (正常)
请老师解答一下!谢谢

 
	
                                                 VIP会员
VIP会员 购物车
购物车

 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
                    
 
                







 
                     
                     
					 
						 
						 
						 
						