title: objects classes and arrays - why is it returning 'null' ? [java]
body: <p>I wrote a small class that creates a report object containing 3 arrays. At creation of the object these arrays are initialised with values. However when i test the class to see for example what's in the departments array, it prints out that the array elements are null. why?</p>
  
  <pre><code> class  Report
   {
          // declare instance variables (arrays)
          public String[] departments = new String[4] ;
          public double[] grossTotals = new double[4] ;
          public double[] taxTotals = new double[4]  ;
  
  
          // constructor
          public Report(){
              // declare, create and initialise all in one statement
              String[] departments = {"Accounting", "Sales", "HR", +
                                                "Administration"} ;
              double[] grossTotals = {0.0, 0.0, 0.0, 0.0} ;
              double[] taxTotals = {0.0, 0.0, 0.0, 0.0} ;
  
      } // END constructor
   } // class  Report
  </code></pre>
  
  <p>Test Class:</p>
  
  <pre><code> class TestReport 
   {
          public static void main(String[] args) {
              // create report object
              Report r = new Report();
  
                  for (int i = 0; i &lt;= 3 ; i++ )
                  {
                  System.out.println(r.departments[i]) ;
                  }
  
          } //end main
   } // end test class
  </code></pre>
  
  <p>thanks</p>
  
  <p>Baba</p>