Thinking in Java Notes

04/08/2008 (week 1)
overloaded methods can have the same name but must have different parameter lists.
----------------
to use finalize( ), it gives you the ability to perform some important cleanup at the time of garbage collection.
finalize( ) can be used for verification of the termination condition of an object.
----------------
Casting from a derived type to a base type moves up on the inheritance diagram, so it’s commonly referred to as upcasting. Upcasting is always safe because you’re going from a more specific type to a more general type.
----------------
With a primitive, final makes the value a constant, but with an object reference, final makes the reference a constant. Once the reference is initialized to an object, it can never be changed to point to another object. However, the object itself can be modified.

In all cases, the blank final must be initialized before it is used, and the compiler ensures this.

Java allows you to make arguments final by declaring them as such in the argument list. This means that inside the method you cannot change what the argument reference points to.

***********************************
20/08/08 (Week 2)

All method binding in Java uses late binding unless a method has been declared final.

When using composition and inheritance to create a new class, most of the time you won’t have to worry about cleaning up—subobjects can usually be left to the garbage collector.

And with inheritance, you must override dispose( ) in the derived class if you have any special cleanup that must happen as part of garbage collection. When you override dispose( ) in an inherited class, it’s important to remember to call the base-class version of dispose( ), since otherwise the base-class cleanup will not happen.

a good guideline for constructors is, “Do as little as possible to set the object into a good state, and if you can possibly avoid it, don’t call any methods.” The only safe methods to call inside a constructor are those that are final in the base class. (This also applies to private methods, which are automatically final.)

25/08/08 (Week 3)

When designing with inheritance, a general guideline is “Use inheritance to express differences in behavior, and fields to express variations in state.”


* haven't read nesting interface and inner class parts.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值