求去掉-的java代码?解决思路

   阅读
求去掉-的java代码?
求去掉-的java代码?
比如102390-363-469,我要把它变成102390363469

------解决方案--------------------
public static void main(String[] args )
{
String test = "102390-363-469 ";
test =test.replaceAll( "- ", " ");
System.out.println(test);
}
------解决方案--------------------
.....我的沙发~~~
------解决方案--------------------
test =test.replaceAll( "- ", " ");
------解决方案--------------------
test =test.replaceAll( "- ", " ");

------解决方案--------------------
test =test.replaceAll( "- ", " ");
------解决方案--------------------
private String name_string(String a)
{

String sss=new String();
sss=a.replaceAll( "- ", " ");
return(sss);
}//转换名字中的空格
}
------解决方案--------------------
public String splitStr(String str) //传入一个 带有 '- '的字符串
{
String new_str=str.replaceAll( "- ", " ");
//对字符串中所有 '- '字符进行取代,取代为 ' '(空字符)
return(new_str); //返回取代后的字符串
}

以上写了一个函数,必须在字符串传进以前做空判断,不然会出现运行时异常,也可如下
String s= "102390-363-469 ";
s=s.replaceAll( "- ", " ");

比较好的方法:
public String splitStr(String str) //传入一个 带有 '- '的字符串
{
if(str!=null && ! " ".equest(str))
{
String new_str=str.replaceAll( "- ", " ");
//对字符串中所有 '- '字符进行取代,取代为 ' '(空字符)
return(new_str); //返回取代后的字符串
}
------解决方案--------------------
str.replaceAll( "- ", " ");

知道这个就可以了,关于条件判断就具体问题具体分析了
------解决方案--------------------
test =test.replaceAll( "- ", " ");
------解决方案--------------------
str.replaceAll( "- ", " ");
阅读