title: How to pass a array to a constructor and use it in a class?
body: <p>This is my main method, i am trying to get back into coding, for i failed at it repeatedly in school. I want to take an array from my main method with user input from a loop, and pass it to a constructor in my "TestScoresTwo.java" class. I want to then take that array and use it to sum the values and find the average in a method in the class, and then return the sum.</p>
  
  <pre><code>import java.math.*;
  import java.text.DecimalFormat;
  import java.io.*;
  
  
  public class labBookFortyTwo
  {
  public static void main(String[] args)
  {
  
  
  Scanner myInput = new Scanner(System.in);
  
  System.out.println("Please enter the amount of grades there are ");
  
  int size = myInput.nextInt();
  
  double grade = 0;
  
  double[] myArray = new double[size];
  
  for(int count = 0; count &lt; myArray.length; count++)
  {
      System.out.println("enter grade ");
  
      grade = myInput.nextDouble();
  
      myArray[count] = grade;
  
      System.out.println("grade is " + myArray[count] );
  
  }
  
  TestScoresTwo myScore = new TestScoresTwo(myArray, size);
  
  double avg = myScore.avgGrade();
  
  System.out.println("avg is" + avg);
  
  
  }
  
  }
  </code></pre>
  
  <p>This is my TestScoresTwo.java Class.</p>
  
  <pre><code>public class TestScoresTwo
  {
  
  int size = 0;
  
  double[] tScore = new double[size];
  
  double sum = 0;
  
  
  
  public TestScoresTwo(double[] scores ,int sizE)
  {
  
      double[] tScore = scores;
  
      size = sizE;
  
  }
  
  
  
  
  public double avgGrade()
  {
  
  
          for(int count = 0; count &lt; tScore.length ; count++) 
          {
              sum = tScore[count] + sum;
  
          }
  
  
      double avg = sum / size;
  
      return avg;
  
  }
  
  }
  </code></pre>
  
  <p>When it compiles my output is:
  "Please enter the amount of grades there are"
  3
  "enter grade"
  11
  "grade is 11.0"
  50
  "grade is 50.0"
  70
  "grade is 70.0"
  "avg" is 0.0"
  "Press any key to continue..."</p>
  
  <p>So for some reason in my class TestScoresTwo.java, the for loop inst being entered, and im not sure why. They are two separate files , and i cant think of any other information to include. Thank you for any help you can give.</p>