![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Java面试题
ZhouHuoCleverset
这个作者很懒,什么都没留下…
展开
-
面试题之获取start到end之间的随机数
需求设计一个方法,获取start到end之间的随机数!分析 Math.random()方法获取0~1之间的随机数,不包含1,返回值类型为double。 获取1~100之间的随机数我们这么做; int num=Math.random()*100+1; 假想1:如果我们要取start到end之间的随机数,那么是不是可以写成: int number=(int)(Math.random()*end+st原创 2017-03-19 00:28:34 · 1410 阅读 · 0 评论 -
String s=new String("hello")与String s="hello"的区别?
题目String s = new String(“hello”)和String s = “hello”;的区别?区别String s = new String(“hello”)会创建2(1)个对象,String s = “hello”创建1(0)个对象。 注:当字符串常量池中有对象hello时括号内成立!引入==与equals()的区别: ==:比较引用类型比较的是地址值是否相同 equals:比原创 2017-03-13 22:57:11 · 17613 阅读 · 8 评论