title: How to implement a unit converter in java
body: <p>How could I possibly implement a unit converter in Java??? I was thinking of having a abstract base class: </p>
  
  <pre><code>public abstract class Unit {
      ...
      public void convertTo(Unit unit);
  }
  </code></pre>
  
  <p>Then having each class like <code>Meter</code> <code>Kilometer</code> <code>Inch</code> <code>Centimeter</code> <code>Millimeter</code> ... derive from that base Unit class. All the units of length would be in a package called com.unitconverter.distance, then a package, com.unitconverter.energy, for energy etc. etc. So is this the best way to implement a unit converter? Or is there a better or more easier way?</p>