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

    }

  • 相关阅读:
    一些数学证明
    重头再来
    二次函数传参
    神经网络
    准备写点随笔了
    如何做出响应式的页面 (转)
    自适应,响应式,viewport总结
    edm邮件制作规范
    博客园blog模板整理
    git 常用的命令
  • 原文地址:https://www.cnblogs.com/connie313/p/10549563.html
Copyright © 2011-2022 走看看