> How to take in multiple user inputs into Java?

How to take in multiple user inputs into Java?

Posted at: 2014-12-18 
import java.util.Scanner;

class Demo {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

String[] inputs = new String[100];

String temp;

int i = -1;

while (true) {

temp = input.nextLine();

if (temp.equals("quit")) {

break;

} else {

i++;

inputs[i] = temp;

}

}

input.close();

for (int j = 0; j < i; j++) {

System.out.println(inputs[j]);

}

}

}

We need to make a program that uses the user input feature, but will take user input until the user types in "quit" to stop the program, and then it will output all of the inputs onto separate lines (minus the quit).

I understand we need to use scanner, but the part that confuses me is the multiple lines of user input.

In my head, I'm thinking an if and else statement, but the problem that comes up in my head is how to strictly make it so that if "quit" is entered that the program will stop.