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()){

    }

  • 相关阅读:
    Java泛型【转】
    沉着
    selenium 自动化测试面试题及答案
    50道JAVA基础编程练习题
    50道JAVA基础编程练习题
    Kibana+Logstash+Elasticsearch 日志查询系统
    Java中this和super的用法总结
    Tensorflow官方文档中文版——第二章(瞎奖杯写)
    LATEX ——WinEdt 破解
    超参数优化
  • 原文地址:https://www.cnblogs.com/connie313/p/10549563.html
Copyright © 2011-2022 走看看