title: How can I update an instance variable with the value of a function variable?
body: <p>I just started programming in android studio in the last few months and i have been wondering , can i update the value of an instance variable with the value of a variable that is in a function? To make this more clear </p>
  
  <p><strong>JAVA CODE</strong>  </p>
  
  <pre><code>public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {
  private FusedLocationProviderClient fusedLocationProviderClient;
                double latitudine, longitudine;
                Location currentLocation;
                Location newLocation;
  
  
  Task location1 = fusedLocationProviderClient.getLastLocation();
                location1.addOnCompleteListener(new OnCompleteListener() {
                @Override
                public void onComplete(@NonNull Task task) {
                if (task.isSuccessful()) {
                   currentLocation = (Location) task.getResult();
  
  
  Toast.makeText(MapsActivity.this,""+currentLocation.getLatitude(),
  Toast.LENGTH_LONG).show();
  
  Toast.makeText(MapsActivity.this,""+currentLocation.getLongitude(),
  Toast.LENGTH_LONG).show();
  
     newLocation = currentLocation ;
              }else{
                  Toast.makeText(MapsActivity.this,"no way",Toast.LENGTH_LONG).show();
              }
          }
      });
  </code></pre>
  
  <p>I simply want to use the value stored in currentLocation in some other places in my project , but how can i do that ? </p>