Java // Loop certain scanner input x amount of times and null print
<pre><code>package test2;

public class Student {

private String Username;
private String Game;
private int score;
private int time;
private String Game2;
private int score2;
private int time2;

public Student() {
    this.Username = null;
    this.Game = null;
    this.score = -1;
    this.time = -1;
    this.Game2 = null;
    this.score2 = -1;
    this.time2 = -1;
}

public Student(String nName, String nGame, int nScore, int nTime,      String nGame2, int nScore2, int nTime2) {
    this.Username = nName;
    this.Game = nGame;
    this.score = nScore;
    this.time = nTime;
    this.Game = nGame2;
    this.score = nScore2;
    this.time = nTime2;
}

public void setUsername(String newUsername) {
    this.Username = newUsername;
}

public void setGame(String newGame) {
    this.Game = newGame;
}

public void setScore(int newScore) {
    this.score = newScore;
}

public void setTime(int newTime) {
    this.time = newTime;
}

public void setGame2(String newGame2) {
    this.Game = newGame2;
}

public void setScore2(int newScore2) {
    this.score = newScore2;
}

public void setTime2(int newTime2) {
    this.time = newTime2;
}

public String getUsername() {
    return Username;
}

public String getGame() {
    return Game;
}

public int getScore() {
    return score;
}

public int getTime() {
    return time;
}
public String getGame2() {
    return Game2;
}

public int getScore2() {
    return score2;
}

public int getTime2() {
    return time2;
}
@Override
public String toString() {
    return "Username: " + this.getUsername() + 
           ", Game: " + this.getGame() +
           ", Time: " + this.getScore() +
           ", Achievement Score: " + this.getTime() +
           ", Game: " + this.getGame2() +
           ", Time: " + this.getScore2() +
           ", Achievement Score: " + this.getTime2();

}

}

package test2;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class test {

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);



    List&lt;Student&gt; Students = new ArrayList();


    Student student1 = new Student();

    student1.setUsername("Bob Marley");
    student1.setGame("GTA 1");
    student1.setScore(1200);
    student1.setTime(150);
    student1.setGame2("GTA 2");
    student1.setScore2(1200);
    student1.setTime2(150);

    Students.add(student1);

    Student student2 = new Student();

    student2.setUsername("Bill Harvey");
    student2.setGame("Minecraft");
    student2.setScore(12001);
    student2.setTime(15);
    student2.setGame2("SHAFT");
    student2.setScore2(12001);
    student2.setTime2(15);

    Students.add(student2);

    Student student3 = new Student();

    student3.setUsername("Dan Marley");
    student3.setGame("The Division");
    student3.setScore(12000);
    student3.setTime(150);
    student3.setGame2("Minecraft");
    student3.setScore2(12001);
    student3.setTime2(15);

    Students.add(student3);


    System.out.println("Add new students: ");
    System.out.println("Enter number of students to add: ");
    int countStudents = input.nextInt();

    for (int i = 0; i &lt; countStudents; i++) {
        Student newStudents = new Student();


        System.out.println("Enter details for student: " + (i + 1));

        System.out.println("Enter Username: ");
        newStudents.setUsername(input.next());

        System.out.println("Enter Game: ");
        newStudents.setGame(input.next());

        System.out.println("Enter Achievement Score: ");
        newStudents.setScore(input.nextInt());

        System.out.println("Enter Time played (Minutes): ");
        newStudents.setTime(input.nextInt());

        System.out.println("Enter Game 2: ");
        newStudents.setGame2(input.next());

        System.out.println("Enter Achievement Score: ");
        newStudents.setScore2(input.nextInt());

        System.out.println("Enter Time played (Minutes): ");
        newStudents.setTime2(input.nextInt());


        Students.add(newStudents);
    }
    System.out.println(Students); 
}
} 
</code></pre>

<p>Here is my coding thus far, problem I am having is the console return "null" from the arraylist, each user should have 2 game of input however the second game is returning as null and I can't see what the problem is.</p>

<pre><code>Add new students: 
Enter number of students to add: 
0
[Username: Bob Marley, Game: GTA 2, Time: 1200, Achievement Score: 150,   Game: null, Time: -1, Achievement Score: -1, Username: Bill Harvey, Game:   SHAFT, Time: 12001, Achievement Score: 15, Game: null, Time: -1,  Achievement Score: -1, Username: Dan Marley, Game: Minecraft, Time: 12001, Achievement Score: 15, Game: null, Time: -1, Achievement Score: -1]
</code></pre>