每天坚持写java锻炼能力---第一天(6.4)

今天的目标是菜单: B站/马士兵的项目菜单

复制代码
package java1;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        while(true){   //3.加入死循环,让输入一直有
            System.out.println();
        System.out.println("--->项目功能如下:<---");
        System.out.println("--->1.展示书籍<---");
        System.out.println("--->2.上架书籍<---");
        System.out.println("--->3.下架书籍<---");
        System.out.println("--->4.退出应用<---");
        System.out.println();
        System.out.println("请输入编号:");
        //1.借助scanner类输入东西
        Scanner sc =new Scanner(System.in);
        int choice =sc.nextInt();  //2.录入数据
        if(choice==1){
            System.out.println("     1.展示书籍");

        }
        if(choice==2){
            System.out.println("     2.上架书籍");

        }
        if(choice==3){
            System.out.println("     3.下架书籍");

        }
        if(choice==4){
            System.out.println("     4.退出应用");
            break;//4.跳出死循环
        }
    }}
}
收获:
复制代码
//1.借助scanner类输入东西
Scanner sc =new Scanner(System.in);

int choice =sc.nextInt();  //2.录入数据

while(true){   //3.加入死循环,让输入一直有
    
break;//4.跳出死循环

今天任务完成每天加油哦

相关推荐
lly2024069 分钟前
Bootstrap 警告框
开发语言
2601_9491465344 分钟前
C语言语音通知接口接入教程:如何使用C语言直接调用语音预警API
c语言·开发语言
曹牧1 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
KYGALYX1 小时前
服务异步通信
开发语言·后端·微服务·ruby
zmzb01031 小时前
C++课后习题训练记录Day98
开发语言·c++
爬山算法2 小时前
Hibernate(90)如何在故障注入测试中使用Hibernate?
java·后端·hibernate
kfyty7252 小时前
集成 spring-ai 2.x 实践中遇到的一些问题及解决方案
java·人工智能·spring-ai
猫头虎2 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven
李少兄2 小时前
在 IntelliJ IDEA 中修改 Git 远程仓库地址
java·git·intellij-idea
YUJIANYUE2 小时前
PHP纹路验证码
开发语言·php