zoukankan      html  css  js  c++  java
  • 阅读:JAVA 3& 4

    • 随机数:
    Random rand = new Random(47); // 产生随机算子。47 is seed. for incovating predicatable random number
    int i = rand.nextInt(100); // 100 is range of random number

    Random()

    “Creates a new random number generator. This constructor sets the seed of the random number generator to a value very likely to be distinct from any other invocation of this constructor. “

    The seed is probably a derivative of the current time, or the current time itself. That should be enough to be “very likely to be distinct from any other invocation”. Which, in essence, is most likely what you need, most of the time.

    So why have another constructor that takes a seed?

    Simply put, if you want to generate the same set of random numbers over and over, you use the same seed on your Random constructor. This is useful when doing experiments on different control sets, and you don’t want to bother creating your own table of random inputs, but still want the same set of random input on a different experiment/control set.

    • 类型确定

    instanceof. String i = ''; i instanceof String. However, i instanceof int will have compiler error.

    • 常量

    Long 3000L/l

    Double 2.33D/d

    Float 3.44f/F

    int i1 = 0x23;
    String ii = Integer.toBinaryString(i1);
    • for-循环

    for(char s: 'hello world'.toCharArray()){

    }

  • 相关阅读:
    SpringBoot整合flyway
    JavaFTP递归查询指定目录下的所有目录和文件
    初识网络设备
    Session
    Cookie
    文件下载
    PHP文件上传
    数据库操作函数笔记
    Apache #Tomcat CVE-2020-9484
    红方人员实战手册
  • 原文地址:https://www.cnblogs.com/connie313/p/10549563.html
Copyright © 2011-2022 走看看