0

I get nullpointer exception every time I tried to run this code,but I do not see anything wrong with this.So here is the code:

@Override
    protected Void doInBackground(Void... params) {
        // Create an array
        arraylist = new ArrayList<HashMap<String, String>>();
        // Retrieve JSON Objects from the given URL address
        jsonobject = JSONfunctions.getJSONfromURL("http://www.focusyazilim.net/json/main.json");

        try {
            // Locate the array name in JSON
            jsonarray = jsonobject.getJSONArray("worldpopulation");

            for (int i = 0; i < jsonarray.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                jsonobject = jsonarray.getJSONObject(i);
                // Retrive JSON Objects
                map.put("şehir", jsonobject.getString("rank"));
                map.put("ülke", jsonobject.getString("country"));
                map.put("nüfus", jsonobject.getString("population"));
                // Set the JSON Objects into the array
                arraylist.add(map);
            }
        } catch (JSONException e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return null;

    }

What can be the problem that can cause nullpointer exception? Here is the error:enter image description here

0 Answers0