《EFFECTIVE JAVA 影印版》求取 ⇩

1 Introduction1

2 Creating and Destroying Objects5

Item 1: Consider providing static factory methods instead of constructors5

Item 2: Enforce the singleton property with a private constructor10

Item 3: Enforce noninstantiability with a private constructor12

Item 4: Avoid creating duplicate objects13

Item 5: Eliminate obsolete object references17

Item 6: Avoid finalizers20

3 Methods Common to All Objects25

Item 7: Obey the general contract when overriding equals25

Item 8: Always override hashCode when you override equals36

Item 9: Always override to String42

Item 10: Override clone judiciously45

Item 11: Consider implementing Comparable53

4 Classes and Interfaces59

Item 12: Minimize the accessibility of classes and members59

Item 13: Favor immutability63

Item 14: Favor composition over inheritance71

Item 15: Design and document for inheritance or else prohibit it78

Item 16: Prefer interfaces to abstract classes84

Item 17: Use interfaces only to define types89

Item 18: Favor static member classes over nonstatic91

5 Substitutes for C Constructs97

Item 19: Replace structures with classes97

Item 20: Replace unions with class hierarchies100

Item 21: Replace enum constructs with classes104

Item 22: Replace function pointers with classes and interfaces115

6 Methods119

Item 23: Check parameters for validity119

Item 24: Make defensive copies when needed122

Item 25: Design method signatures carefully126

Item 26: Use overloading judiciously128

Item 27: Return zero-length arrays, not nulls134

Item 28: Write doc comments for all exposed API elements136

7General Programming141

Item 29: Minimize the scope of local variables141

Item 30: Know and use the libraries145

Item 31: Avoid float and double if exact answers are required149

Item 32: Avoid strings where other types are more appropriate152

Item 33: Beware the performance of string concatenation155

Item 34: Refer to objects by their interfaces156

Item 35: Prefer interfaces to reflection158

Item 36: Use native methods judiciously161

Item 37: Optimize judiciously162

Item 38: Adhere to generally accepted naming conventions165

8 Exceptions169

Item 39: Use exceptions only for exceptional conditions169

Item 40: Use checked exceptions for recoverable conditions and run-time exceptions for programming errors172

Item 41: Avoid unnecessary use of checked exceptions174

Item 42: Favor the use of standard exceptions176

Item 43: Throw exceptions appropriate to the abstraction178

Item 44: Document all exceptions thrown by each method181

Item 45: Include failure-capture information in detail messages183

Item 46: Strive for failure atomicity185

Item 47: Don't ignore exceptions187

9 Threads189

Item 48: Synchronize access to shared mutable data189

Item 49: Avoid excessive synchronization196

Item 50: Never invoke wait outside a loop201

Item 51: Don't depend on the thread scheduler204

Item 52: Document thread safety208

Item 53: Avoid thread groups211

10 Serialization213

Item 54: Implement Seriali zable judiciously213

Item 55: Consider using a custom serialized form218

Item 56: Write readobj ect methods defensively224

Item 57: Provide a readResol ve method when necessary230

References233

Index of Patterns and Idioms239

Index241

《EFFECTIVE JAVA 影印版》由于是年代较久的资料都绝版了,几乎不可能购买到实物。如果大家为了学习确实需要,可向博主求助其电子版PDF文件。对合法合规的求助,我会当即受理并将下载地址发送给你。