I'm doing a lab that requires a continuation question, but no matter what I do, the program always stops before accepting an answer. Here is my main method:
import java.util.Scanner;
import static java.lang.System.*;
public class Lab03b
{
public static void main( String args[] )
{
Scanner scan = new Scanner(in);
boolean ans = true;
do{
out.println("Enter the word to display:: ");
String word = scan.nextLine();
out.println("Enter the number of times to display:: ");
int times = scan.nextInt();
out.println("Do you wish to continue? (y/n):: ");
String choice = scan.nextLine();
WordPrinter.printWord(word,times);
if (choice == "y" || choice == "Y")
{ ans = true;
}
else
{
ans = false;
}
} while(ans == true);
}
}
It references another class that goes through a basic loop to print out a word x amount of times. Any help is appreciated.