这两天闲在家,又不能看电脑,只好看看书,把《Practical Java》 过了一遍。比较早的一本书,2000年的,主要是jjhou译的,当时就买了。
PJ 总的来说,相对不算深入,不过是初学者很容易犯的一些错误,讲解了一些不易于理解的地方。下面是书中的几大章节。
1. General Techniques, 基础知识
http://kasicass.blog.163.com/blog/static/395619200942462240444http://kasicass.blog.163.com/blog/static/395619200942454665032. Objects and Equality, 两个对象相等的各种问题
http://kasicass.blog.163.com/blog/static/3956192009424113557923. Exception Handling
http://kasicass.blog.163.com/blog/static/395619200942695156572/4. Performance
设计搞好,先测量,再优化。2080原则。
5. Multithreading
如何正确使用 keyword 'synchronized',“lock data, not lock method”, "class object and instance is not the same”
6. Classes and Interfaces
interface, abstract class, class 之间的关系。
class 没啥说的;interface 只能有 method declaration,没有 implemtation。
abstract class,不能实例化的 class,可以有 method 的实现,也可以有 abstract method(无实现)。
在 new 的同时立即 override abstract method,可以~
public abstract class HelloWorld {
void fooBar() {
System.out.println("foobar");
}
public static void main(String[] args) {
HelloWorld hw = new HelloWorld() {
void fooBar() {
System.out.println("override");
}
};
hw.fooBar();
}
}
评论