Skip to main content
  • For Enterprise
  • For Government
  • For Higher Ed
  • For Individuals
  • For Content Marketing
O'Reilly home
    • For Enterprise
    • For Government
    • For Higher Ed
    • For Individuals
    • For Marketing
    • Explore Skills
      • Cloud Computing
        • Microsoft Azure
        • Amazon Web Services (AWS)
        • Google Cloud
        • Cloud Migration
        • Cloud Deployment
        • Cloud Platforms
        • View All
      • Data Engineering
        • Data Warehouse
        • SQL
        • Apache Spark
        • Microsoft SQL Server
        • MySQL
        • Kafka
        • Data Lake
        • Streaming & Messaging
        • NoSQL Databases
        • Relational Databases
        • View All
      • Data Science
        • Pandas
        • R
        • MATLAB
        • SAS
        • D3
        • Power BI
        • Tableau
        • Statistics
        • Exploratory Data Analysis
        • Data Visualization
        • View All
      • AI & ML
        • Generative AI
        • Machine Learning
        • Artificial Intelligence (AI)
        • Deep Learning
        • Reinforcement Learning
        • Natural Language Processing
        • TensorFlow
        • Scikit-Learn
        • Hyperparameter Tuning
        • MLOps
        • View All
      • Programming Languages
        • Java
        • JavaScript
        • Spring
        • Python
        • Go
        • C#
        • C++
        • C
        • Swift
        • Rust
        • Functional Programming
        • View All
      • Software Architecture
        • Object-Oriented
        • Distributed Systems
        • Domain-Driven Design
        • Architectural Patterns
        • View All
      • IT/Ops
        • Kubernetes
        • Docker
        • GitHub
        • Terraform
        • Continuous Delivery
        • Continuous Integration
        • Database Administration
        • Computer Networking
        • Operating Systems
        • IT Certifications
        • View All
      • Security
        • Network Security
        • Application Security
        • Incident Response
        • Zero Trust Model
        • Disaster Recovery
        • Penetration Testing / Ethical Hacking
        • Governance
        • Malware
        • Security Architecture
        • Security Engineering
        • Security Certifications
        • View All
      • Design
        • Web Design
        • Graphic Design
        • Interaction Design
        • Film & Video
        • User Experience (UX)
        • Design Process
        • Design Tools
        • View All
      • Business
        • Agile
        • Project Management
        • Product Management
        • Marketing
        • Human Resources
        • Finance
        • Team Management
        • Business Strategy
        • Digital Transformation
        • Organizational Leadership
        • View All
      • Soft Skills
        • Professional Communication
        • Emotional Intelligence
        • Presentation Skills
        • Innovation
        • Critical Thinking
        • Public Speaking
        • Collaboration
        • Personal Productivity
        • Confidence / Motivation
        • View All
      • View All
    • Features
      • All Features
      • Courses
      • Certifications
      • Interactive Learning
      • Live Events
      • Answers
      • Insights Reporting
    • Radar Blog
    • Buy Courses
    • Plans
    • Sign In
    • Try Now

Effective Java, 3rd Edition by Joshua Bloch

Get full access to Effective Java, 3rd Edition and 60K+ other titles, with a free 10-day trial of O'Reilly.

There are also live events, courses curated by job role, and more.

Start your free trial

Contents

Foreword

Preface

Acknowledgments

1   Introduction

2   Creating and Destroying Objects

Item 1:   Consider static factory methods instead of constructors

Item 2:   Consider a builder when faced with many constructor parameters

Item 3:   Enforce the singleton property with a private constructor or an enum type

Item 4:   Enforce noninstantiability with a private constructor

Item 5:   Prefer dependency injection to hardwiring resources

Item 6:   Avoid creating unnecessary objects

Item 7:   Eliminate obsolete object references

Item 8:   Avoid finalizers and cleaners

Item 9:   Prefer try-with-resources to try-finally

3   Methods Common to All Objects

Item 10: Obey the general contract when overriding equals

Item 11: Always override hashCode ...

Get Effective Java, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Start your free trial

Follow us

linkedin logo youtube logo

About O’Reilly

  • Teach/Write/Train
  • Careers
  • O’Reilly News
  • Media Coverage
  • Community Partners
  • Affiliate Program
  • Submit an RFP
  • Diversity
  • Content Sponsorship

Support

  • Contact Us
  • Newsletters
  • Privacy Policy
  • AI Policy

International

  • Australia & New Zealand
  • Japan

Download the O’Reilly App

Take O’Reilly with you and learn anywhere, anytime on your phone and tablet.

Apple app store Google play store

Watch on Your Big Screen

View all O’Reilly videos, virtual conferences, and live events on your home TV.

Roku Players and TVs Amazon appstore
O'Reilly home

Do not sell or share my personal information.

© 2025, O’Reilly Media, Inc. All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.

Terms of Service • Privacy Policy • Editorial Independence • Modern Slavery Act Statement

Don’t leave empty-handed

Get Mark Richards’s Software Architecture Patterns ebook to better understand how to design components—and how they should interact.

It’s yours, free.

Get it now
Cover of Software Architecture Patterns

Check it out now on O’Reilly

Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems every day.

Start your free trial Become a member now