title: Store the main class values in subclass as an Array
body: <p>Please help me to add array in Student class. i will input the values in main class which needs to be stored in student class and then can be displayed by calling method ShowData().</p>
  
  <pre><code>import java.util.Scanner;
  </code></pre>
  
  <p>public class Library {</p>
  
  <pre><code>public static void main(String[] args) {
      Student record = new Student();
      int roll;
      String name;
      int mob;
      int i;
  
      Scanner sc = new Scanner(System.in);
  
      System.out.println("Enter roll numer of student \n");
      roll = sc.nextInt();
      System.out.println("Enter name of the student \n");
      name = sc.next();
      System.out.println("Enter mobile number of the student \n");
      mob = sc.nextInt();
  
      record.getData(roll, name, mob);
  
  record.showData();
  }
  }
  </code></pre>
  
  <p>This is a subclass Student</p>
  
  <p>public class Student {</p>
  
  <pre><code>int roll;
  String name;
  int mob;
  int i = 0;
  
  void getData(int roll, String name, int mob) {
  
      this.roll = roll;
      this.name = name;
      this.mob = mob;
  
  }
  
  void showData() {
  
      //for(i=0; i &lt; 3; i++)
  
      System.out.println("roll number " + roll + "\nname " +  name + "\nmobile number " + mob);
  }
  }
  </code></pre>