62,614
社区成员
发帖
与我相关
我的任务
分享
String s = new String();
while (!s.matches("\\d+")) {
s = JOptionPane.showInputDialog(null, "hi", "heihei");
}
利用正则表达式不断的循环判断是否全为数字 最终得到的s就是纯数字的 亲测有效 String inputValue = JOptionPane.showInputDialog("请输入您要取款的金额");
//long money = Integer.parseInt(inputValue);
if(inputValue == null){
return ;
}
if(!inputValue.equals("")){
try{
long money = Integer.parseInt(inputValue);
if(money>999999){
JOptionPane.showMessageDialog( null,
" 输入的金额数不能大于6位数","金额错误",JOptionPane.PLAIN_MESSAGE );
}
}catch(Exception e){
JOptionPane.showMessageDialog( null,
" 输入金额错误或","金额错误",JOptionPane.PLAIN_MESSAGE );
}
}
问题没有,只是说这样的话不够友好!