diff --git a/core/java/android/util/MapCollections.java b/core/java/android/util/MapCollections.java index 28b788b97aa7c..80ab23c8261d7 100644 --- a/core/java/android/util/MapCollections.java +++ b/core/java/android/util/MapCollections.java @@ -22,6 +22,7 @@ import java.lang.reflect.Array; import java.util.Collection; import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; /** @@ -52,6 +53,7 @@ abstract class MapCollections { @Override public T next() { + if (!hasNext()) throw new NoSuchElementException(); Object res = colGetEntry(mIndex, mOffset); mIndex++; mCanRemove = true; @@ -87,6 +89,7 @@ abstract class MapCollections { @Override public Map.Entry next() { + if (!hasNext()) throw new NoSuchElementException(); mIndex++; mEntryValid = true; return this;