zoukankan      html  css  js  c++  java
  • 学Java第三天

    学习内容

    1.比较

    自动售票机的代码,展现了比较的含义

    投入足够的钱币或者硬币,自动打印出车票并找回零钱

    //初始化
      Scanner in = new Scanner (System.in);
     //读入投币金额
      System.out.println("请投币");
      int amount = in.nextInt();
      System.out.println(amount);
      System.out.println(amount>=10);
      //打印车票
      System.out.println("河北省石家庄市专线");
      System.out.println("无指定座票位");
      System.out.println("票价:10元");
      //计算并打印找零
      System.out.println("找零:"+"amount-10");

    2.判断

    判断两个数的大小

    Scanner in = new Scanner (System.in);

    int x = in.nextInt();

    int y = in.nextInt();

    int max;

    System.out.println(max);

    判断三个数大小,可应用嵌套和级联的if

    3.分支

    switch和case

    switch(控制表达式){

    case 常量;

    语句

    ......

    case 常量;

    语句

    ......

    default:

    语句

    ......

    }

    如果没有default,那就什么也不做。

    break

    执行完分支的最后一个语句,如果没有break,则执行到下面的case。

    困难

    在循环知识中,对于经典的十个数排序,冒泡排序,快速排序,归并排序等不会区分,不会编写。

    明天要学习的:排序的一些方法,数组。

  • 相关阅读:
    [uboot] (番外篇)uboot relocation介绍(转)
    [uboot] (番外篇)global_data介绍(转)
    [uboot] (第三章)uboot流程——uboot-spl代码流程 后续2018版本分析
    AddressUtils
    ruoyi HttpUtils
    ruoyi IpUtils
    ruoyi StringUtils
    JSONObject
    jackson解析处理JSON
    spring boot pom demo
  • 原文地址:https://www.cnblogs.com/SirNie/p/13268667.html
Copyright © 2011-2022 走看看