{
  "id": "java/string-index-out-of-bounds-exception",
  "signature": "java.lang.StringIndexOutOfBoundsException: String index out of range: 10",
  "signature_zh": "java.lang.StringIndexOutOfBoundsException: 字符串索引超出范围: 10",
  "regex": "java\\.lang\\.StringIndexOutOfBoundsException: String index out of range",
  "domain": "java",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "An attempt to access a character in a String using an index that is negative or greater than or equal to the string length, often due to off-by-one errors or malformed input.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试使用负数或大于等于字符串长度的索引访问字符串中的字符，通常由差一错误或格式错误的输入引起。",
  "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": "This hides the bug and may cause downstream issues like null pointer exceptions or incorrect data processing.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This does not address the root cause of incorrect index calculation; the index may still be out of range for other inputs.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check the string length before accessing: if (index >= 0 && index < str.length()) { char c = str.charAt(index); } else { /* handle error */ }",
      "success_rate": 0.95,
      "how": "Check the string length before accessing: if (index >= 0 && index < str.length()) { char c = str.charAt(index); } else { /* handle error */ }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use str.substring(start, end) with bounds checking, or use str.charAt(Math.min(index, str.length()-1)) as a temporary clamp.",
      "success_rate": 0.8,
      "how": "Use str.substring(start, end) with bounds checking, or use str.charAt(Math.min(index, str.length()-1)) as a temporary clamp.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check the string length before accessing: if (index >= 0 && index < str.length()) { char c = str.charAt(index); } else { /* handle error */ }",
    "Use str.substring(start, end) with bounds checking, or use str.charAt(Math.min(index, str.length()-1)) as a temporary clamp."
  ],
  "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/StringIndexOutOfBoundsException.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-12-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}