title: .getWidth(), .getHeight() in Java
body: <p>So I just started learning Java yesterday coming from a different language, and I am reading through my textbook and finding it to be pretty nice so far. However I did an exercise that basically required me to create a new Object use Rectangle and find the area. Below is the working code I came up with.</p>
  
  <p>Now coming from other programming languages I was just toying around with this and did <code>int area,width,height;</code>and then it gave me an error saying that I had to use double in order to utilize <code>.getWidth();, .getHeight()</code>. I couldn't find anything in my book telling me why I had to make this a double and I started looking online and found this link</p>
  
  <p>Now I found some documentation online where It told me to use double as well, but I'm not really sure why would I need to set these as doubles. Is it because the people who made Java, knew that precision is needed when we are working with coordinates and doing math with widths, heights and coordinates? My book says that it takes more memory to make a <code>double</code> variable rather than an <code>int</code> ( I come from doing lots of javascript and PHP, so reading on what a <code>float</code> and <code>double</code> does was something good for me). </p>
  
  <p>I.E. Why do I need to make my <code>area,height,width</code> variable doubles in order to use <code>.getWidth,.getHeight</code></p>
  
  <pre><code>package keepo;
  import java.awt.Rectangle;
  public class tuna{
      public static void main(String [] args){
          Rectangle rect = new Rectangle(10,20,50,40);
          double area,width,height;
          width = rect.getWidth();
          height = rect.getHeight();
          area = width * height;
          System.out.println("Width is : " + width + "Height is : " + height);
          System.out.println("Area is : " + area);
      }
  }
  </code></pre>