String x = "string";
String y = "string";
String z = new String("string");
System.out.println(x==y); // true
System.out.println(x==z); // false
System.out.println(x.equals(y)); // true
System.out.println(x.equals(z)); // true
String str1 = "通话";String str2 = "重地";System.out.println("str1 hashcode=>"+str1.hashCode());System.out.println("str2 hashcode=>"+str2.hashCode());System.out.println(str1.equals(str2));
hashcode是通过hash函数得来的,hashcode是在hash表中对应的位置,hashcode提高查找的快捷性,首先比较hashcode,然后比较equals,重写了equals要重写hashcode。
System.out.println("1.4 round结果" + und(1.4));
System.out.println("1.5 round结果" + und(1.5));
System.out.println("1.6 round结果" + und(1.6));
System.out.println("2.4 round结果" + und(2.4));
System.out.println("2.5 round结果" + und(2.5));
System.out.println("2.6 round结果" + und(2.6));
System.out.println("-1.4 round结果" + und(-1.4));
System.out.println("-1.5 round结果" + und(-1.5));
System.out.println("-1.6 round结果" + und(-1.6));
System.out.println("-2.4 round结果" + und(-2.4));
System.out.println("-2.5 round结果" + und(-2.5));
System.out.println("-2.6 round结果" + und(-2.6));
运行结果为:
1.4 round结果1
1.5 round结果2
1.6 round结果2
2.4 round结果2
2.5 round结果3
2.6 round结果3
-1.4 round结果-1
-1.5 round结果-1
-1.6 round结果-2
-2.4 round结果-2
-2.5 round结果-2
-2.6 round结果-3
规律就是这个数加上0.5向下取整。
本文发布于:2024-02-04 21:27:32,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170716820459767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |