Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:09:15+00:00 2026-05-25T22:09:15+00:00

In Effective Java , Bloch recommends to make all the fields final in making

  • 0

In Effective Java, Bloch recommends to make all the fields final in making an object immutable .

Is it necessary to do so ? Won’t just not giving accessor methods make it immutable.

For example

class A {
      private int x;
      A (int x) {
          this.x = x;
      }
}

The above class is immutable even if I don’t declare x as final right ? Am I missing something ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:09:16+00:00Added an answer on May 25, 2026 at 10:09 pm

    In addition to @Bozho’s point, declaring a field as final means that it can be safely accessed without any synchronization.

    By contrast, if the field is not final there is a small risk that another thread will see an anomalous value for the field if it accesses it without proper synchronization. This can happen even if nothing changes the field’s value after object construction!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Effective Java says that readResolve works only if all fields are transient .
Joshua Bloch's Effective Java, Item 51 is not about depending on the thread scheduler
In his talk about Effective Java at 54:15 Joshua Bloch recommends to use get
In his book Effective Java , Joshua Bloch recommends against using Interfaces to hold
I was reading Joshua Bloch's Effective Java Programming Language Guide . He explains static
I am reading Effective Java by Joshua Bloch. At the top of page 16,
Effective java says: // Potential security hole! static public final Thing[] VALUES = {
from p.46 Effective Java Joshua Bloch. Item 9: ALways override hashCode when you override
I read Effective Java by Joshua Bloch and removed the 'Constant Interface anti-pattern' from
I'm currently reading Effective Java by Joshua Bloch and Item 17 is 'Design and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.