当前位置: 技术问答>java相关
再JAVA中有没有将"123,456,789"中逗号去掉的方法
来源: 互联网 发布时间:2015-09-28
本文导语: 再JAVA中有没有将"123,456,789"中逗号去掉的方法 | java.util.StringTokenizer st = new StringTokenizer("123,456,789",","); StringBuffer sb = new StringBuffer(); while(st.hasMoreTokens()) { sb.append(st.nextToken()); } ...
再JAVA中有没有将"123,456,789"中逗号去掉的方法
|
java.util.StringTokenizer st = new StringTokenizer("123,456,789",",");
StringBuffer sb = new StringBuffer();
while(st.hasMoreTokens()) {
sb.append(st.nextToken());
}
StringBuffer sb = new StringBuffer();
while(st.hasMoreTokens()) {
sb.append(st.nextToken());
}
|
有,用NumberFormat
|
String str=new String("123,456,789");
str = str.replace(',','') ;
str = str.replace(',','') ;