zoukankan      html  css  js  c++  java
  • 4-10记录

    静态方法:用static标识、

    返回类型:方法执行完后的结果。 方法可以没有返回类型,用void标识。void就是没有返回类型。一个方法只能有一个返回类型。

    形参:方法声明时的参数。

    实参:方法调用时的参数。

    方法的返回值可以不去接收。编译不会出错。但是没有返回值就不能去接收。

    三目运算符(三元运算符):  boolean f = a>b? true:false  

    位运算符:计算机计算乘法最快就是使用位运算。 如2*8 =》 2<<3

    /*
     英中学员状态转换器
    */
    import java.util.*;
    public class Test{
     public static void main(String[] args){
     System.out.println("*********欢迎使用学员状态转换器********");
     putIn();
     System.out.println("退出系统!");
     }

     //转换
     public static void conversion(String str){
      if(str.equals("E")||str.equals("e")){
       System.out.println("优秀");
      }else if(str.equals("G")||str.equals("g")){
       System.out.println("良好");
      }else if(str.equals("S")||str.equals("s")){
       System.out.println("中等");
      }else if(str.equals("F")||str.equals("f")){
       System.out.println("不合格");
      }else{
       System.out.println("输入错误,无法转换");
      }
     }

     //输入
     public static void putIn(){
      Scanner sc = new Scanner(System.in);
      boolean isCarryOver = true;
      while(isCarryOver){
       System.out.print(" 请输入学员状态的第一个英文字母:");
       String letter = sc.nextLine();
       conversion(letter);

       while(true){
        System.out.print(" 您想继续吗? (y/n)");
        String str = sc.nextLine();
        if(str.equals("y")){
         break;
        }else if(str.equals("n")){
         isCarryOver = false;
         break;
        }else{
         System.out.println(" 输入错误,请重新输入!"); 
        }
       }
       System.out.println();
      }
     }

  • 相关阅读:
    (9)springboot+redis实现session共享-copy
    (8)RestTemplate真实案例-copy
    (7)一秒完成springboot与logback配置-copy
    (6)前后端分离之Swagger2-copy
    (5)springboot+druid连接池及监控配置-copy
    (4)springboot不同环境打包-copy
    (3) springboot-多模块构建-copy
    (2)springboot项目快速构建-copy
    oracle查看被锁的表和解锁
    过年回家抢票,让光猫自动重启的小脚本
  • 原文地址:https://www.cnblogs.com/zouguangyi/p/3657614.html
Copyright © 2011-2022 走看看