1,三大语句
break语句
break用于while循环里,通常用来跳出循环;
contiune语句
用来终结循环;
returm语句
break,continue结合语句
实题演练:
package manager; import java.util.Scanner; public class d1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int choice; String name; do{ System.out.println("-------欢迎使用miniDVD------"); System.out.println("-------------------------"); System.out.println("----------功能选项----------"); choice = input.nextInt(); switch(choice){ case 1 : System.out.println("新增DVD"); System.out.println("请输入你需要新增DVD的名称"); name = input.next(); System.out.println("新增《"+name+"》成功"); do{ System.out.println("输入0返回"); choice = input.nextInt(); }while(choice!=0); break; case 2 : System.out.println("查看DVD"); do{ System.out.println("输入0返回"); choice = input.nextInt(); }while(choice!=0); break; case 3: System.out.println("删除DVD"); System.out.println("请输入你删除的DVD名称"); name = input.next(); System.out.println("删除《"+name+"》成功"); do{ System.out.println("输入0返回"); choice = input.nextInt(); }while(choice!=0); break; case 4: System.out.println("借出DVD"); System.out.println("请输入你借出的DVD名称"); name = input.next(); System.out.println("借出《"+name+"》成功"); do{ System.out.println("输入0返回"); choice = input.nextInt(); }while(choice!=0); break; case 5: System.out.println("归还DVD"); System.out.println("请输入归还DVD名称"); name = input.next(); System.out.println("归还《"+name+"》成功"); do{ System.out.println("输入0返回"); choice = input.nextInt(); }while(choice!=0); break; case 6: System.out.println("退出系统"); break; default: System.out.println("输入错误"); }; }while(true); } }