package cn.itcast.作业; import java.util.Scanner; public class Demo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = null; while (true) { System.out.println("请输入你要写的:"); s = sc.next(); if (s.equals("exit")) { System.out.println("谢谢光临,程序退出"); System.exit(0); } else { System.out.println("你输入你的有误,请重新输入:"); } } } } |