输入n之后要怎么才能返回问题

我输入n之后没办法再继续输入了 不知道该怎么改

import java.util.Scanner;
public class Loop {
public static void main(String[]args){
System.out.println("Please enter y or n");
Scanner in =new Scanner(System.in);
String response = in.nextLine();
while (response.equals("n")){
System.out.println("Please enter y or n");
return;
}
while((!response.equals("n"))&&(!response.equals("y"))){
System.out.println("Invalid input");
System.out.println("Please enter y or n");
return;
}
if(response.equals("y")){
System.out.println("Great! Let's get started!");
}
}

}

现在看CSS书籍的时候,关于伪元素before和after用法,用百度搜索了一下,发现用到网页中怎么都不起效果。
在w3school给出的before(after)的定义如下:伪元素在元素之前(后)添加内容。这个伪元素允许创作人员在元素内容的最前面(后面)插入生成内容;
例如我用工具MyEclipse新建一个html文件,测试css before和after的效果,但是不起作用,后来研究了......
答案就在这里:你的CSS before和after不起效果 看看是不是我这种情况
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

import java.util.Scanner;

public class Loop {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please enter y or n");
do{
String response = in.nextLine();
if ((!"n".equals(response)) && (!"y".equals(response))) {
System.out.println("Invalid input");
System.out.println("Please enter y or n");
}
if ("n".equals(response)) {
System.out.println("Please enter y or n");
}
if ("y".equals(response)) {
System.out.println("Great! Let's get started!");
return;
}
}while(true);
}
}
不知道能不能达到你的要求。equals比较时我把字符串放前面也是一个小建议,因为输入的字符串不确定,有可能是null,就会出现空指针异常。

import java.util.Scanner;

public class Loop {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please enter y or n");
do{
String response = in.nextLine();
if ((!"n".equals(response)) && (!"y".equals(response))) {
System.out.println("Invalid input");
System.out.println("Please enter y or n");
}
if ("n".equals(response)) {
System.out.println("Please enter y or n");
}
if ("y".equals(response)) {
System.out.println("Great! Let's get started!");
return;
}
}while(true);
}
}
不知道能不能达到你的要求。equals比较时我把字符串放前面也是一个小建议,因为输入的字符串不确定,有可能是null,就会出现空指针异常。

import java.util.Scanner;

public class Loop {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please enter y or n");
do{
String response = in.nextLine();
if ((!"n".equals(response)) && (!"y".equals(response))) {
System.out.println("Invalid input");
System.out.println("Please enter y or n");
}
if ("n".equals(response)) {
System.out.println("Please enter y or n");
}
if ("y".equals(response)) {
System.out.println("Great! Let's get started!");
return;
}
}while(true);
}
}
不知道能不能达到你的要求。equals比较时我把字符串放前面也是一个小建议,因为输入的字符串不确定,有可能是null,就会出现空指针异常。