title: Java: String Formatting
body: <p>Attempting to print out...</p>
  
  <pre><code>64506 St. Joseph, MO (+39.76580, +94.85060)
  </code></pre>
  
  <p>Current Code</p>
  
  <pre><code>public class PostalCodes {
  private String city;
  private double latitude;
  private double longitude;
  private double zip;
  private String state;
  
  public PostalCodes(double aZip, String aCity, String aState, double aLatitude, double aLongitude)
  {
      city = aCity;
      latitude = aLatitude;
      longitude = aLongitude;
      zip = aZip;
      state = aState;
  }
  
  void setZip(double aZip)
  {
      zip=aZip;
  }
  
  void setState(String aState)
  {
      state=aState;
  }
  
  
  void setLocation(String aCity)
  {
      city = aCity.trim();
  }
  void setLatitude(double lat)
  {
      latitude = lat;
  }
  void setLongitude(double long1)
  {
      longitude = long1;
  }
  public String getState()
  {
      return state;
  }
  public double getZip()
  {
      return zip;
  }
  public String getLocation()
  {
      return city;
  }
  public double getLatitude()
  {
      return latitude;
  }
  public double getLongitude()
  {
  return longitude;
  }
  public String toString()
  {
      String result = String.format("%d %s,%s (%1.3f; %1.3f)",zip, city, state, latitude,longitude);
      return result;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I'm getting </p>
  
  <pre><code>Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
  at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
  at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
  at java.util.Formatter$FormatSpecifier.print(Unknown Source)
  at java.util.Formatter.format(Unknown Source)
  at java.util.Formatter.format(Unknown Source)
  at java.lang.String.format(Unknown Source)
  at PostalCodes.toString(PostalCodes.java:63)
  </code></pre>
  
  <p>As an error. I did it exactly how I had down in my notes from class, not sure where I'm going wrong here. Thanks for your time and dumb it down for me if you could, first time Java programmer over here.</p>