I want to give user a possibility to stop inputing new lines in my String array by entering the word "end". I checked out - it really inputs 'end' before the if statement, but for some reason this doesn't break the while cycle:
Scanner scan = new Scanner(System.in);
String[] str = new String[50];
int j=0;
int f = 0;
System.out.println("Input 'end' to see your previous input!");
while(f != -1)
{
the input goes well, but the if statement doesn't work completely
String choice = scan.nextLine();
if(choice == "end")
{
f = -1;
}
else
{
str[j] = choice;
j++;
}
}