{
  "id": "java/numberformatexception-for-input-string",
  "signature": "java.lang.NumberFormatException: For input string: \"...\"",
  "signature_zh": "java.lang.NumberFormatException: 对于输入字符串: \"...\"",
  "regex": "java\\.lang\\.NumberFormatException: For input string: \\\"",
  "domain": "java",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Attempting to parse a string that does not contain a parsable number, often due to whitespace, null, or unexpected characters.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试解析一个不包含可解析数字的字符串，通常由于空白字符、null 或意外字符。",
  "versions": [
    {
      "version": "Java 8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Using Integer.valueOf() without try-catch on user input will crash the application if input is invalid.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Assuming locale-specific number formats (e.g., commas in European locales) are supported by default can cause parsing failures.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use try-catch with NumberFormatException and provide a default value: 'int value; try { value = Integer.parseInt(input.trim()); } catch (NumberFormatException e) { value = 0; }'",
      "success_rate": 0.9,
      "how": "Use try-catch with NumberFormatException and provide a default value: 'int value; try { value = Integer.parseInt(input.trim()); } catch (NumberFormatException e) { value = 0; }'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Validate input with a regex before parsing: 'if (input != null && input.matches(\"\\\\d+\")) { int value = Integer.parseInt(input); } else { /* handle error */ }'",
      "success_rate": 0.85,
      "how": "Validate input with a regex before parsing: 'if (input != null && input.matches(\"\\\\d+\")) { int value = Integer.parseInt(input); } else { /* handle error */ }'",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use try-catch with NumberFormatException and provide a default value: 'int value; try { value = Integer.parseInt(input.trim()); } catch (NumberFormatException e) { value = 0; }'",
    "Validate input with a regex before parsing: 'if (input != null && input.matches(\"\\\\d+\")) { int value = Integer.parseInt(input); } else { /* handle error */ }'"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/NumberFormatException.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-03-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}