0
驗證一個整數值,如何通過形式在Java通過形式
if(!(Integer.parseInt(txtStart.getText()).equals(txtStart.getText()))
{
JOptionPane.showMessageDialog(null, "Please Enter Valid Start Page");
}
驗證一個整數值,如何通過形式在Java通過形式
if(!(Integer.parseInt(txtStart.getText()).equals(txtStart.getText()))
{
JOptionPane.showMessageDialog(null, "Please Enter Valid Start Page");
}
驗證一個整數值,隨着下一個代碼,你可以驗證你的文字是一個數字。
public class Main {
public static void main(String args[]){
String txtValue1 = "";
String txtValue2 = "a";
String txtValue3 = "3";
System.out.println("txtValue1: "+isNumber(txtValue1));
System.out.println("txtValue2: "+isNumber(txtValue2));
System.out.println("txtValue3: "+isNumber(txtValue3));
}
private static boolean isNumber(String _value){
boolean result = true;
try{
Double.parseDouble(_value);
}catch(Exception e){
result = false;
}
return result;
}
}
輸出
txtValue1: false
txtValue2: false
txtValue3: true
非常感謝你可租可買它幫助我 –
請不要忘記額定問題 –