zoukankan      html  css  js  c++  java
  • JDK9版本以上Java独有的一个轻量级小工具,你知道吗?jshell

    jshell,是JavaJDK9这个大版本更新以来,带来的一个轻量级小工具。我们再也不用进入Java目录,编写一个Java文件,然后再去编译,最后才能执行它。

    这里,你可以直接写一个小功能,就能去实现它。这就是jshell带来的一个小便利。

    介绍:jshell这是Java用来写脚本的轻量小工具。

     
    • 直接输入:jshell进入
    • 退出: 输入/exit   记得一定要加/
    
    对于byte/short/char/三种类型来说,如果右侧赋值的数值没有超过范围,
    那么Javac编译器将会自动隐含的为我们补上一个(byte)(short)(char)。
    
    byte num1 = 30//30
    //int-->byte ,不是自动类型转换
    //int-->char ,不是自动类型转换
    char zifu = /*(char)*/65//A 可以操作
    
    注意:
    如果没有超过左侧的范围,编译器补上强转。
    如果右侧超过了左侧的范围,那么直接编译器报错。、
    ============================== 注意:常量可以自动优化,如果是变量就不可以了。 short a = 3; short b = 7; short result = 3+7; //short = result = a + b;// 报错,不可以运行 System.out.println(result);//可以运行
  • 相关阅读:
    AtCoder Grand Contest 015 题解
    AtCoder Grand Contest 014 题解
    AtCoder Grand Contest 013 题解
    AtCoder Grand Contest 012 题解
    AtCoder Grand Contest 011 题解
    AtCoder Grand Contest 010 题解
    AtCoder Grand Contest 009 题解
    NOIP2017 Day2 题解
    博客园主题备份
    多项式全家桶
  • 原文地址:https://www.cnblogs.com/cainiao-chuanqi/p/11051813.html
Copyright © 2011-2022 走看看