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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:39:59+00:00 2026-06-11T05:39:59+00:00

I know the usual reasons that apply to general immutable classes, viz can not

  • 0

I know the usual reasons that apply to general immutable classes, viz

  1. can not change as a side effect
  2. easy to reason about their state
  3. inherently thread safe
  4. no need to provide clone/copy constructor/factory copy method
  5. instance caching
  6. no need for defensive copies.

However, wrapper classes represent primitive types, and primitive types are mutable. So why aren’t wrapper classes mutable?

  • 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-11T05:40:00+00:00Added an answer on June 11, 2026 at 5:40 am

    However, wrapper classes represent primitive types, and primitive types (except String) are mutable.

    Firstly, String isn’t a primitive type.

    Secondly, it makes no sense to talk about the primitive types being mutable. If you change the value of a variable like this:

    int x = 5;
    x = 6;
    

    That’s not changing the number 5 – it’s changing the value of x.

    While the wrapper types could have been made mutable, it would have been annoying to do so, in my view. I frequently use readonly collections of these types, and wouldn’t want them to be changeable. Very occasionally I want a mutable equivalent, but in that case it’s easy enough to come up with one, or use the Atomic* classes.

    I find myself wishing that Date and Calendar were immutable far more often than I find myself wanting Integer to be mutable… (Of course I normally reach for Joda Time instead, but one of the benefits of Joda Time is immutability.)

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

Sidebar

Related Questions

I know you can not set a key value dynamically, but what about the
I know there are lots of tools on the net that can make our
I am relatively new to ASP.NET so I do not know the usual practice
I know the usual cause for this issue is related to the platform that
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still
Anyone know how I can make a login button in Ruby on Rails for
I know that if port 443 is open that means the remote host supports
Does anyone know why istream object can be used as bool expression? For example:
We all know the usual use of templates to design containers and we all

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.