title: object within object java
body: <p>So I'm trying to make it so that when the user creates a new PlaceInformation object, the inputted latitude and longitude are stored inside of the GeoLocation object place. Obviously, upon running the "client" code, the GeoLocation object is initialized first and is given a value of 0.0, 0.0 instead of what the user inputs. How do I make it so that the latitude and longitude parameters from the constructor store in the GeoLocation object? I tried it a different way but there were some scope issues.</p>
  
  <pre><code>public class PlaceInformation {
      private String name;
      private String tag;
      private String address;
      private double latitude;
      private double longitude;
      GeoLocation place = new GeoLocation(latitude, longitude);
  
  
      public PlaceInformation(String name, String address, String tag,
                          double latitude, double longitude) {
          this.name = name;
          this.address = address;
          this.tag = tag;
          this.latitude = latitude;
          this.longitude = longitude;
      }
  
  
  
      public String getName() {
          return name;
      }
  
      public String getAddress() {
          return address;
      }
  
      public String getTag() {
          return tag;
      }
  
      public String toString() {
          return name + ", " + address;
      }
  
      public double test() {
          return place.getLongitude();
      }
  
      public double distanceFrom(GeoLocation spot) {
          return spot.distanceFrom(place);
      }
  }
  </code></pre>