随笔分类 -  常用代码

摘要:1、过滤所有数字 String regEx="[0-9]"; Pattern p=Pattern.compile(regEx); Matcher m=p.matcher(str); m.replaceAll("").trim(); 2、过滤所有非数字字符 String regEx="[^0-9]"; 阅读全文
posted @ 2016-04-05 23:10 Maydow 阅读(115) 评论(0) 推荐(0)
摘要:char 与int 1、int 转换成char: int n = 1; char ch = (char)(n + '0'); 这样打印出来ch的值为1; 不过需要注意(因为char只有一个字节),此处的n只能是0-9之间的字符 2、char转换成Int: char ch = '9'; int n = 阅读全文
posted @ 2015-05-05 14:28 Maydow 阅读(175) 评论(0) 推荐(0)