2017年10月11日
摘要:
不覆盖equals方法,在这种情况下,类的每个实例都只与它自身相等,如果满足了一下任何一个条件,这就正是所期望的结果类的每个实例本质上都是唯一的不关心类是否提供了“逻辑相等”的测试功能超类已经覆盖了equals,从超类继承过来的行为对于子类也是合适的。类是私有的或是包级私有的,可以确定他的equal
阅读全文
posted @ 2017-10-11 15:36
飞奔的菜鸟
阅读(180)
推荐(0)
2017年9月29日
摘要:
鉴于包装类的“==”在不遇到算数运算的情况下不会自动拆箱(但是看上面的输出好像可以自动拆箱) 以及它们的equals()方法不处理数据转型的关系
阅读全文
posted @ 2017-09-29 21:20
飞奔的菜鸟
阅读(115)
推荐(0)
2017年9月28日
摘要:
Java虚拟机在重载时是通过参数的静态类型而不是实际类型作为判定依据的。 Human man = new Man(); Human被称为变量的静态类型,Man称为变量的实际类型
阅读全文
posted @ 2017-09-28 15:32
飞奔的菜鸟
阅读(235)
推荐(0)
2017年9月26日
摘要:
class staticTset{ static class Parent{ public static int K = 1; static {//静态代码块中只能访问到定义在静态代码块之前的变量 K = 2; } } static class Sub extends Parent{ public
阅读全文
posted @ 2017-09-26 22:31
飞奔的菜鸟
阅读(183)
推荐(0)
2017年9月25日
摘要:
class ConstClass{ static { System.out.println("ConstClass init"); } public static final String HELLOWORLD = "hello world";}class NotInitialzation{ pub
阅读全文
posted @ 2017-09-25 23:47
飞奔的菜鸟
阅读(356)
推荐(0)
摘要:
class superclass{ static { System.out.println("superclass init"); } public static int value = 123;}class subclass extends superclass{ static { System.
阅读全文
posted @ 2017-09-25 23:03
飞奔的菜鸟
阅读(249)
推荐(0)