I am taking a course and I have the programs run in a loop so you can easily exit by entering "Quit". I am running into trouble working with arrays. This has the user type in sentences and then at the end shows the user what they typed. I want to have the program check each input the user types in and if it is "Quit", I want to exit the program. I am new to Java so looking for something that is within my understanding without using a break if possible.
I have attempted to use a boolean in my while loop to quit when it is set to false.
public static void main(String[] args)
{
String [] Responses = new String [10];
boolean ExitLoop = true;
do
{
Scanner Input = new Scanner(System.in);
int n = 0;
for (int i = 0; i < 10; i++)
{
System.out.println("Please enter sentence " + (i+1) + ": ");
Responses[n] = Input.nextLine();
if (Responses[n] == "Quit")
{
ExitLoop = false;
}
n++;
}
System.out.println();
for (int j = 0; j < 10; j++)
{
System.out.println("Sentence " + (j+1) + " " + Responses[j]);
}
}
while (ExitLoop);
}