我就想实现键盘输入pro1的时候打印pro1 输入pro2的时候打印pro2 输入exit的时候退出程序 并且可以循环输入直直退出 实际运行效果是不管输入什么打印的都是"Reinput",知道这里大牛多,别笑话我啊~~
import java.io.*;public class TestWhile{ public static void main(String[] args){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); while(s != "exit"){ while(s == "pro1"){ System.out.println("pro1"); s = br.readLine(); } while(s == "pro2"){ System.out.println("pro2"); s = br.readLine(); } while((s != "pro1")&&(s != "pro2")&&(s != "exit")){ System.out.println("Reinput"); s = br.readLine(); } } } catch(IOException e){ e.printStackTrace(); } System.out.println("The end"); } }