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 9264841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:55:23+00:00 2026-06-18T13:55:23+00:00

From the famous book Java Concurrency in Practice chapter 3.4.1 Final fields Just as

  • 0

From the famous book Java Concurrency in Practice chapter 3.4.1 Final fields

Just as it is a good practice to make all fields private unless they
need greater visibility[EJ Item 12] , it is a good practice to make
all fields final unless they need to be mutable.

My understanding of final references in Java : A final reference/ field just prevents the the field from getting re initialized but if it references a mutable object , we can still change its state rendering it mutable . So I am having difficulty understanding the above quote . What do you think ?

  • 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-06-18T13:55:24+00:00Added an answer on June 18, 2026 at 1:55 pm

    final fields prevent you from changing the field itself (by making it “point” to some other instance), but if the field is a reference to a mutable object, nothing will stop you from doing this:

    public void someFunction (final Person p) {
        p = new Person("mickey","mouse"); //cant do this - its final
        p.setFirstName("donald");
        p.setLastName("duck");
    }
    

    the reference p above is immutable, but the actual Person pointed to by the reference is mutable.
    you can, of course, make class Person an immutable class, like so:

    public class Person {
        private final String firstName;
        private final String lastName;
        public Person(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
        }
        //getters and other methods here
    }
    

    such classes once created, cannot be modified in any way.

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

Sidebar

Related Questions

Taking this snippet from the famous agile web development with rails book (most recent
I have created a simple test (just to download a file from famous site
From Spring Projects Issue Tracker Beans: public class JavaBean { private NestedBean nested; }
I am trying to migrate to svn from a not-so-famous version control system (lets
I am using yaml for layout and famous clearfix css to make sure container
I am trying to understand the algorithm from the famous 'diff' paper here ,
Even famous sites like Twitter are suffering from XSS vulnerability, what should we do
The title comes from the famous site C++ FAQ by Marshall Cline. The author
The NQueen problem is a famous example of backtracking . After reading from the
I'm using a API to get some photos from a famous web. And I

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.