中級 › NumberFormatException の原因と直し方 › パターン4
NumberFormatException の原因と直し方
parseIntは全体が数値でなければ失敗します。
1 public class Main { 2 public static void main(String[] args) { 3 String s = ________; ^ 4 System.out.println(Integer.parseInt(s)); 5 } 6 }
Exception in thread "main" java.lang.NumberFormatException: For input string: "1,000"exited with code 1
空欄を埋めてビルドを通す
カンマ区切りの数字はparseIntが理解できません。カンマを取り除いてから渡します。
次の問題