{"record":{"id":"f1186414bc5f77b9","repo":"Blankj/AndroidUtilCode","slug":"entry-does-not-exist","errorCode":null,"errorMessage":"Entry does not exist: {}","messagePattern":"Entry does not exist: (.+?)","errorType":"exception","errorClass":"IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"lib/utilcode/src/main/java/com/blankj/utilcode/util/CollectionUtils.java","lineNumber":730,"sourceCode":"        if (object instanceof Map) {\n            Map map = (Map) object;\n            Iterator iterator = map.entrySet().iterator();\n            return get(iterator, index);\n        } else if (object instanceof List) {\n            return ((List) object).get(index);\n        } else if (object instanceof Object[]) {\n            return ((Object[]) object)[index];\n        } else if (object instanceof Iterator) {\n            Iterator it = (Iterator) object;\n            while (it.hasNext()) {\n                index--;\n                if (index == -1) {\n                    return it.next();\n                } else {\n                    it.next();\n                }\n            }\n            throw new IndexOutOfBoundsException(\"Entry does not exist: \" + index);\n        } else if (object instanceof Collection) {\n            Iterator iterator = ((Collection) object).iterator();\n            return get(iterator, index);\n        } else if (object instanceof Enumeration) {\n            Enumeration it = (Enumeration) object;\n            while (it.hasMoreElements()) {\n                index--;\n                if (index == -1) {\n                    return it.nextElement();\n                } else {\n                    it.nextElement();\n                }\n            }\n            throw new IndexOutOfBoundsException(\"Entry does not exist: \" + index);\n        } else {\n            try {\n                return Array.get(object, index);\n            } catch (IllegalArgumentException ex) {","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/Blankj/AndroidUtilCode/blob/7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809/lib/utilcode/src/main/java/com/blankj/utilcode/util/CollectionUtils.java#L712-L748","documentation":"Thrown by CollectionUtils.get when the object is an Iterator (or a Map/Collection, which are reduced to an iterator) and the iterator is exhausted before the requested index is reached. Note the index is decremented during iteration, so the reported value is the residual count (<= 0), not the original index. Map entries are indexed via their entrySet iterator.","triggerScenarios":"Calling get on a Map/Collection/Iterator with an index >= the number of available elements; iterating a one-shot Iterator that had already been partially consumed before the call.","commonSituations":"Assuming a Map's position matches insertion order without an ordered map; requesting an index larger than size(); reusing a Stream/Iterator that has already advanced; off-by-one when index equals size().","solutions":["Bound the index against the known size before calling get (index < size).","For positional access prefer a List (uses List.get directly) over a Map/Iterator.","Do not reuse a one-shot Iterator across multiple get() calls; obtain a fresh iterator each time.","For Map access, use the key directly instead of a positional index."],"exampleFix":"// before\nObject v = CollectionUtils.get(map, map.size()); // Entry does not exist\n\n// after\nObject v = CollectionUtils.get(map, map.size() - 1); // last valid index","handlingStrategy":"validation","validationCode":"int size = CollectionUtils.size(object);\nif (index >= 0 && index < size) {\n    Object v = CollectionUtils.get(object, index);\n} else {\n    // index past the end of an iterator-backed collection\n}","typeGuard":null,"tryCatchPattern":"try {\n    v = CollectionUtils.get(object, index);\n} catch (IndexOutOfBoundsException e) {\n    v = null; // iterator exhausted before index\n}","preventionTips":["Bound the index against size() before calling get on Map/Collection/Iterator.","Prefer List.get for positional access; reserve get() for genuinely unknown types.","Never reuse a one-shot Iterator across multiple get() calls."],"tags":["collection","index-out-of-bounds","iterator","map","collectionutils","java"],"backgroundTag":null,"analyzedSha":"7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809","analyzedAt":"2026-08-14T02:26:54.956Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}