问题1:取模运算符%就是除之取余数,rand.nextInt() 是随机生成数int类型,它% 100得到的就是除于100的余数,自然就是从0到99了,这样就控制了范围……和10000没有任何关系问题2:java是分大小写的,什么时候大写,什么时候小写,对于系统类型和class而言,大小写是强制规定的,没有二话,至于你自己定义的,class第一个字母一般大写,方法第一个字母一般小写,当然并不是绝对……其它参考匈牙利命名法……

解决方案 »

  1.   

    >>int最大取值难道是10000吗?
    你是怎么得出这个结论的?:)
    nextInt 
    public int nextInt() 
    Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. The general contract of nextInt is that one int value is pseudorandomly generated and returned. All 232 possible int values are produced with (approximately) equal probability. The method nextInt is implemented by class Random as follows:  
    public int nextInt() {  return next(32); }
    Returns:
    the next pseudorandom, uniformly distributed int value from this random number generator's sequence至于大小写,如果是你自己定义的方法或变量,可以由你自己来随意决定,如果你是要用类库中的方法或字段,那就必须注意大小写了,保持与类库中的一致。