title: Array Guessing game - How to set and get an array?
body: <p>I am trying to create a guessing game where the user enters a name and is </p>
  
  <p>prompted to pick a number 5 times. I am trying to store the numbers in an array and use set and get methods to print out the attributes of the array. I have achieved this for the name but I am unable to set and get the array. </p>
  
  <pre><code>import java.util.Scanner;
  
  public class StudentStore
  {
  
      private String n1;//store's the player's name
      //private int [] s10;  //stores the player's score
      private int i;
      private int noOfPlayers = 5;
      private int[] s10 = new int[noOfPlayers];
      Scanner kboardIn = new Scanner(System.in);
      private int index;
      int newInt = 0;
  
  
      public StudentStore(String n1, int [] s10, int i )
      {
  
              this.n1 = n1;
              this.s10[i] = s10[i];
              this.setName(n1);
              //this.i = i;
              this.setScore(s10,i);
              //this.index = index;
          //  PlayerScore.incNumberScores();
      }
  
      public void setScore( int []s10, int i)
      {
          //takes an integer score, sets variables and checks topScore
          this.s10[i] = s10[i];
          //this.checkAndSetTopScore();
      }
  
      public int [] getScore()
      {
  
          return this.s10;
      }
  
      public void setName(String n1)
      {
          this.n1 = n1;
      }
  
      public String getName()
      {
          return this.n1;
      }
  }
  
  import java.util.Scanner;
  
  public class StudentTester
  {
      public static void main(String args[])
      {
  
          Scanner kboardIn = new Scanner(System.in);
  
          int noOfStudents;
  
          System.out.print("Enter the number of students: ");
          noOfStudents = kboardIn.nextInt();
          //int[] noOfStudents;
          //noOfStudents = new int[100];
  
  
  
  
          StudentStore[] student1 = new StudentStore[noOfStudents];
  
          //int s1 = 0;
          int noOfPlayers = 5;
          int[] s10 = new int[noOfPlayers];
          //s10 = 0;
          String n1 = "something";
          int i = 0;
  
          for (int index = 0; index &lt; student1.length; index++)
              student1[index] = new StudentStore(n1, s10, i);
  
              for (int index = 0; index &lt;= student1.length; index++)
              {
  
  
                  System.out.print("What is name of student no "+(index+1)+" ?");
                  n1 = kboardIn.next();
                  student1[index].setName(n1);
                  System.out.print("What is mark for student no "+(index+1)+" ?");
                  for(i=0; i &lt; noOfPlayers; i++)
                  {
                      s10[i] = kboardIn.nextInt();
                      student1[index].setScore(s10, i);
                      System.out.println("This is it" + s10[i]);
                  }
                  System.out.println(student1[index].getScore(      ));
                  System.out.println(student1[index].getName());
                  System.out.println(index);
                  System.out.println(s10[index]);
                  System.out.println(i);
                  //System.out.println(s10[]);
  
              }
  
  
  
  
          for (int index = 0; index &lt; student1.length; index++)
  
              System.out.println("\nTotal Mark for " + student1[index].getName()+ " is\t" + student1[index].getScore());
  
      }
  }
  </code></pre>