title: How can I return value from function onResponse of Retrofit?
body: <p>I'm trying to return a value that i get from <code>onResponse</code> method in <code>retrofit</code> call request, is there a way that i can get that value out of the overrided method? here is my code: </p>
  
  <pre><code>public JSONArray RequestGR(LatLng start, LatLng end)
      {
         final JSONArray jsonArray_GR;
  
          EndpointInterface loginService = ServiceAuthGenerator.createService(EndpointInterface.class);    
          Call&lt;GR&gt; call = loginService.getroutedriver();
          call.enqueue(new Callback&lt;GR&gt;() {
              @Override
              public void onResponse(Response&lt;GR&gt; response , Retrofit retrofit)
              {
  
                   jsonArray_GR = response.body().getRoutes();
  //i need to return this jsonArray_GR in my RequestGR method
              }
              @Override
              public void onFailure(Throwable t) {
              }
          });
          return jsonArray_GR;
      }
  </code></pre>
  
  <p>i can't get the value of <code>jsonArray_GR</code> because to be able to use it in <code>onResponse</code> method i need to declare it final and i can't give it a value.</p>