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

    }

  • 相关阅读:
    进程、线程、协程
    C++内存模型
    动态库dll与静态库lib
    virtual 虚函数表
    C++面试随笔
    alloc()、malloc()、calloc()、realloc()区别及用法
    C/C++ 面试题记录
    VC底层钩子程序在Win7/Vista下无效
    JMeter安装之后修成中文版
    明天开始 新的旅程
  • 原文地址:https://www.cnblogs.com/connie313/p/10549563.html
Copyright © 2011-2022 走看看