http://www.verejava.com/?id=16992628432522
/**
连续录入学生姓名,输入“q”则系统退出
*/
import java.util.Scanner;
public class DoWhile2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请连续录入学生姓名, 直到输入q退出系统");
String name = "";
do {
name = in.nextLine();
} while (!name.equals("q"));
System.out.println("退出系统");
}
}
/*
while循环和do-while循环的区别?
*/