title: Why not instance variable?
body: <p>I'm relatively new to Java (I'm taking AP computer science) and the book I have, Big Java, poses this question:</p>
  
  <blockquote>
    <p>Consider the following implementation of a class Square:</p>
  
  <pre><code>public class Square {
  
      private int sideLength;
  
      private int area; // Not a good idea
  
      public Square(int length) {
  
          sideLength = length; }
  
      public int getArea() {
  
          area = sideLength * sideLength;
  
          return area; }
  }
  </code></pre>
    
    <p>Why is it not a good idea to introduce an instance variable for the
    area? Rewrite the class so that area is a local variable.</p>
  </blockquote>
  
  <p>I'm sure the answer is obvious to a more experienced coder but I'm really unsure why making area an instance variable is a bad approach. Any guidance would be much appreciated!</p>