I would like to create option with do while were user after inputting correct letter will get out of the loop. I have try to make one but if I put while(type == "Y") it just throws me out of the loop doesn't matter what I press or if I out while(type != "Y") it is going in loop forever, so I am doing somewhere else wrong but I can not figure it out where.
public class JavaApplication8 {
static String type;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
do {
System.out.println("Press Y to get out of the loop");
type = scanner.next();
} while (type == "Y");
}
}