zoukankan      html  css  js  c++  java
  • JAVA笔记1__基本数据类型/输入输出/随机数/数组

    /**八种基本数据类型
            boolean
            byte
            short
            int
            long
            char
            float
            double
    */
    public class test1{
        public static void main(String[] args){
            long g = 1000L;
            float f = 3.14F;
            double d = 10.12345d;
        }
    }
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            int a = input.nextInt();
            int b = input.nextInt();
            System.out.println("a+b = "+(a+b));
        }
    }
    import java.util.Random;
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            /**
             * 数组三种方式:
             * int x[]; //先声明
             * 2.int[] x = new int[3];
             * 3.int[] x = new int[]{3,4,5};
             * 4.int[] x = {1,2,3,4};
             * 求数组长度:x.length
             */
            Random r = new Random();
            //返回一个伪随机数,它是取自此随机数生成器序列的、在 0(包括)和指定值(不包括)之间均匀分布的 int 值。
            int x = r.nextInt(10);
            System.out.println(x);
        }
    }
  • 相关阅读:
    vue跨域代理配置
    vue中引入jquery
    vue中使用特殊字体
    vue中使用mockjs
    vue中使用动态echart图表
    解决win10休眠后无法唤醒
    nvm-windows的安装配置
    黑苹果快捷键
    python基础知识
    如何高效的学习python
  • 原文地址:https://www.cnblogs.com/fish7/p/4135971.html
Copyright © 2011-2022 走看看