How to return a variable that is in JsonArray Request
<p>I use JsonArrayRequest inside a method(function), that return number.I use function JsonArrayRequest when I need it.<br><br> 
But some issue: function return wrong number, in code below function have to return variable lastNumber, i.e last number of variable i. Sorry if my qustion stupid, couse I am new in java and android.<br><br> Note, function return the lastNumber when it used a second time. I suggest that the program in first time  is not implement JsonArrayRequest.
I following this tutorial <a href="http://www.androidhive.info/2014/05/android-working-with-volley-library-1/" rel="nofollow">http://www.androidhive.info/2014/05/android-working-with-volley-library-1/</a> .Any help appreciate!<br><br></p>

<pre><code>public int lastNumber = 0;    
private int makeJsonObjectRequest(int startList,int endList) {
            JsonArrayRequest movieReq = new JsonArrayRequest(url,
                    new Response.Listener&lt;JSONArray&gt;() {
                        @Override
                        public void onResponse(JSONArray response) {
                            Log.d(TAG, response.toString());
                            i = startLsit;
                            while(i &lt; endList) {
                                try {
                                    JSONObject obj = response.getJSONObject(i);
                                    Movie movie = new Movie();

                                  /***** TONS OF CODE  *****/

                                        movieList.add(movie);
                                    }

                                    }
                                } catch (JSONException e) {
                                    e.printStackTrace();

                                }
                              i++;
                              lastNumber = i;
                            }
                            mAdapter.notifyDataSetChanged();
                        }
                    }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    VolleyLog.d(TAG, "Error: " + error.getMessage());
                    hidePDialog();
                }
            });
            AppController.getInstance().addToRequestQueue(movieReq);
            return lastNumber
        }
</code></pre>