title: Unable to print json value to a integer array list? is saves there but unable to take out off the loop?
body: <p>Can anybody help me to take the <code>arraylist</code> out of the loop. If I take it out, it's coming empty as array out of bound. Here is my code:</p>
  
  <pre><code>public void collapse() {
      corequestQueue= Volley.newRequestQueue(getApplicationContext());
      String url="http://192.168.43.208/online/json.php";
      JsonObjectRequest jsonObjectRequest3=new JsonObjectRequest(Request.Method.GET, url,
          new Response.Listener&lt;JSONObject&gt;() {
              @Override
              public void onResponse(JSONObject response) {
                  try {
                      JSONArray jsonArray=response.getJSONArray("server_responce");
                      for (int i=0;i&lt;=jsonArray.length();i++){
  
                          JSONObject admin=jsonArray.getJSONObject(i);
  
                          solution.add(Integer.valueOf(admin.getString("sno")));
  
                      //if i do like this the values prints here in the toast.        
                      //Toast.makeText(User_Login.this, "hello"+solution.get(0), Toast.LENGTH_SHORT).show();
                      //printing the toast anywhere out of the block gives error.. as assay out of bound 0 on index size 0.. help me guys
                      }
  
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          },
          new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  Log.e("Volly","error");
              }
          }
  
          );
      corequestQueue.add(jsonObjectRequest3);
      Toast.makeText(User_Login.this, "hello"+solution.get(0), Toast.LENGTH_SHORT).show();
  }
  </code></pre>
  
  <p>The last line gives me error I can't take the array list anywhere outside because it's coming out empty. It's perfect when it is inside the loop and values are adding to it. I have checked it, only thing is I cant take it out?</p>