求去掉-的java代码? 求去掉-的java代码?比如102390-363-469,我要把它变成102390363469 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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("-", ""); java中JFrame类中 公共方法调用 奇怪的变量。。 一条JAVA笔试题 IP连接问题 多个RandomAccessFile 同时往一个文件中写数据如何保证写入的正确性 文件传输问题,高手帮忙!!! 向高人请教JAVA JTable用法. 一个问题关于reference variable 求最好的加密class文件的工具及下载地址 帮我看看这段程序好吗?不知道为什么点鼠标就是没有反应 如何做这样的java程序 帮忙找个错误。急!
{
String test ="102390-363-469";
test =test.replaceAll("-", "");
System.out.println(test);
}
{ String sss=new String();
sss=a.replaceAll("-","");
return(sss);
}//转换名字中的空格
}
{
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); //返回取代后的字符串
}