Java classes and Scanner
<p>I am learning java and started with classes and I am now having some doubts.</p>

<p>I'm going to make a program with data from students, classes and chairs. For example information from the student data will be used in classrooms and chairs. For now, I will restrict myself to the class student.</p>

<p>Each student will have a name and birth date.
I thought I'd create a class with student data and then save the data of students in two arrays. One-dimensional array of strings for the names and an array with three columns for the dates (year, month, day).</p>

<p>I started by creating the Student class with the code:</p>

<pre><code>    public class Stundent{
        private String nameStudent;
        private int yearBirth;
        private int monthBirth;
        private int dayBirth;

        public void setName(String name){
            System.out.println("Insert student's name:");
            nameStudent = name;

        }
        public String getName(){
            return nameStudent;
        }
        public void setYear(int year){
            System.out.println("Insert student's year of birth:");
            yearBirth = year;
        }
        public int getYear(){
            return yearBirth;
        }
        public void setMonth(int month){
            System.out.println("Insert student's month of birth:");
            monthBirth = month;
        }
        public int getMonth(){
            return monthBirth;
        }
        public void setDay(int day){
            System.out.println("Insert student's day of birth:");
            dayBirth = day;
        }
        public int getDay(){
            return dayBirth;
        }
    }
</code></pre>

<p>Then in the main file had thought this way:</p>

<pre><code>            Student person = new Student();
            String[] nameStudents = new String[100];
            int[][] birthdayStudents = new int[100][3];
            for (int i = 0; i &lt; 3; i++){

                person.setName(sc.nextLine());
                nameStudents[i] = person.getName();

                person.setAno(sc.nextInt());
                birthdayStudents[i][1] = person.getAno();

                person.setMes(sc.nextInt());
                birthdayStudents[i][1] = person.getMes();

                person.setDia(sc.nextInt());
                birthdayStudents[i][2] = person.getDia();

            }
</code></pre>

<p><strong>First question:</strong></p>

<p>Forgetting that this not working properly because the scanner, is this the correct way of thinking?</p>

<p><strong>Second question:</strong></p>

<p>If I run this code I have the following situation:
It will be presented to me "Insert student's name:" but if I place Maria  InputMismatchException will appear. I believe he is storing Maria in the year.
Why does this happen? In the same for cycle I can't have more than one call to the scanner?
If I only put in the code:</p>

<pre><code>person.setName(sc.nextLine());
nameStudents[i] = person.getName();
</code></pre>

<p>and remove everything else concerning the birthday it will work OK.
Can anyone enlighten me?</p>
