title: java: abstract classes and its variables
body: <p>I am fairly new to java so I tried to implement an example and use abstract classes
  but my lack of OO knowledge makes me wonder why I cannot use a private variable from the abstract class in a "concrete" class extending it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>abstract class Equation{
      private double[] c;//oefficient
      public static int degree(double[] coeff) {
          return coeff.length;
      }
      public abstract double[] solve();
  }
  
  class QuadraticEquation extends Equation{
      public double[] solve() {
          double[] solution;
          double discriminant = c[1]*c[1]-4*c[0]*c[2];
          if (discriminant &lt; 0) {
              solution = new double[] {Double.NaN,Double.NaN};
          }
          else {
              solution = new double[] {(c[1]+Math.sqrt(discriminant))/(2*c[0])
                                      ,(c[1]-Math.sqrt(discriminant))/(2*c[0])};
          }
          return solution;
      }
  }
  </code></pre>
  
  <p>The Error I get is </p>
  
  <pre><code> c has private access in Equation
  </code></pre>
  
  <p>i could resolve this by making <code>c</code> a <code>public</code> variable, but I guess there is a better way to do this.</p>
  
  <p>Bottom Line: How do I access the variable <code>c</code>.</p>