package com.maxmind.geoip2.record;

import java.util.*;
import org.json.*;

public abstract class RecordWithNames {

    private HashMap<String, String> names;
    private Integer geoNameId;
    private Integer confidence;

    protected RecordWithNames(JSONObject json) throws JSONException {
        geoNameId = json.getInt("geoname_id");
        names = new HashMap<String, String>();
        if (json.has("names")) {
            JSONObject jnames = json.getJSONObject("names");
            for (Iterator<String> i = jnames.keys(); i.hasNext();) {
                String key = i.next();
                String value = jnames.getString(key);
                names.put(key, value);
            }
        }
        if (json.has("confidence")) {
            confidence = new Integer(json.getInt("confidence"));
        }
    }

    protected RecordWithNames() {
        names = new HashMap<String, String>();
    }

    public String getName(String l) {
        return names.get(l);
    }

    public int getGeoNameId() {
        return geoNameId;
    }

    public Integer getConfidence() {
        return confidence;
    }
}

@@ -491,13 +491,8 @@
     
-for (
 Iter
@@ -496,22 +496,17 @@
 terator%3C
-String
+?
 %3E i = jn
@@ -517,17 +517,36 @@
 .keys();
- 
+%0A            while (
 i.hasNex
@@ -552,11 +552,9 @@
 xt()
-;) 
+)
 %7B%0A  
@@ -579,16 +579,25 @@
 ng key =
+ (String)
  i.next(

Use a while loop rather than a c-style for loop