title: Why Line by line execution does not happen in Android Studio?
body: <p>I have created a <code>Place[]</code> type array <code>p</code> to store the place obtained through <code>fetchPlace()</code> method. I have just shown the some lines code of a function which I have to call. But when I call this function the 1st <code>logd</code> line is executed first which shows value of <code>p[0]</code> as <code>null</code>. As fetching a place takes some time, so I delayed 2nd <code>logd</code> line. Here, p[0] is not null. Please have a look at the code below:</p>
  <pre><code>final Place[] p = new Place[1];
  
  final String placeId = place.get(&quot;place_id&quot;);
  
          final List&lt;Place.Field&gt; placeFields = Arrays.asList(
                  Place.Field.PHONE_NUMBER,
                  Place.Field.LAT_LNG
          );
  
          final FetchPlaceRequest request = FetchPlaceRequest.newInstance(placeId, placeFields);
  
          placesClient.fetchPlace(request).addOnSuccessListener((response) -&gt; {
  
              p[0] = response.getPlace();
              
          }).addOnFailureListener((exception) -&gt; {
              Log.i(TAG, &quot;Place not found: &quot; + exception.getMessage());
          });
  
          Log.d(TAG, &quot;Place: &quot; + p[0]);
          
          new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {
                  Log.d(TAG, &quot;Place Delayed: &quot; + p[0]);
              }
          }, 1000);
  </code></pre>
  <p>Here is the two <code>logd</code> outputs:
  <strong>1st</strong> : <code>D/MapsFragment: Place: null</code>
  <strong>2nd</strong> : <code>D/MapsFragment: Place Delayed: Place{address=null, addressComponents=null, businessStatus=null, attributions=[], id=null, latLng=lat/lng: (19.0255944,73.0935353), name=null, openingHours=null, phoneNumber=+91 1800 208 1234, photoMetadatas=null, plusCode=null, priceLevel=null, rating=null, types=null, userRatingsTotal=null, utcOffsetMinutes=null, viewport=null, websiteUri=null}</code></p>
  <p>I want to ask why does the code inside <code>addOnSuccessListener</code> doesn't run before <code>logd</code> which is below it ?
  Thanks in advance !</p>