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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:53:13+00:00 2026-05-15T18:53:13+00:00

Why to use primitive types in java instead of Wrapper classes? I want to

  • 0

Why to use primitive types in java instead of Wrapper classes? I want to know that already we have wrapper classes in java, then why we need to use primitive types? What are the importance of primitive types in java?

  • 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-15T18:53:13+00:00Added an answer on May 15, 2026 at 6:53 pm

    Your question is backwards. The primitive types are more fundamental than their wrappers.

    Really the only useful thing that wrappers give you is the ability to be treated as a subclass of Object (so that they can be put into collections and so on). All the really useful stuff (like arithmetic and ordering) is provided by the primitive type.

    Note that while you can say stuff like:

    Integer i = Integer.valueOf(4);
    Integer j = Integer.valueOf(2);
    Integer k = i + j;
    

    this is just a convenience. Underneath, the last line becomes something like:

    Integer k = Integer.valueOf(i.intValue() + j.intValue());
    

    so that the arithmetic occurs on the primitive values. (This convenience is known as boxing/unboxing.) There is a performance penalty to this, so that on my machine, this loop:

    for (int i=0; i<10000000; i++) { }
    

    is about 10 times faster than this loop:

    for (Integer i=0; i<10000000; i++) { }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Mixing the use of primitive data types and their respective wrapper classes, in Java,
Since Java 5, we've had boxing/unboxing of primitive types so that int is wrapped
In which case should you use primitive types( int ) or reference types (
In Java, most of the primitive types are signed (one bit is used to
In my schema I have some types that simply extend a simple XSD type
In Java, when we want to ensure that compiler should not do optimization by
The Java Virtual Machine Specification says that there is limited support for boolean primitive
I want to use Class.getMethod(String name, Class... parameterTypes) to find the method I need
I am confused about when to use primitive vs. non-primitive(?) types (i.e. int vs.
I have been trying to understand the use of primitives in Java and C#

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.