我是靠谱客的博主 悲凉棒棒糖,这篇文章主要介绍java while的用法case_java while和switch-case循环,现在分享给大家,希望可以做个参考。

import java.util.Scanner;

public class xunhuan {

public static void main(String[] args){

Scanner e=new Scanner(System.in);//标准语句,申明并开启系统标准处理(键盘输入

//int m=e.nextInt();//m为可以手动输入的整数

System.out.println("输入想要循环的次数");

int mm=e.nextInt();//生成一个键盘输入的int

int i=1;

while (i<=mm){//开启循环,设置循环结束条件

System.out.println("输入选择");

int m=e.nextInt();//m为可以手动输入的整数

switch (m){//switch case 用法

case 1:System.out.println("李看看"); break;

case 2:System.out.println("李搞搞"); break;

case 3:System.out.println("李上演"); break;

case 4:System.out.println("李小凡"); break;

default: System.out.println("输入错误") ;

//i++之前我写在这里,一直思考为什么我设置的结束条件没用,要注意结构层次

}

i++;

}

}

}

最后

以上就是悲凉棒棒糖最近收集整理的关于java while的用法case_java while和switch-case循环的全部内容,更多相关java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部