Results 1 to 5 of 5
  1. #1
    asif_plz is offline Member
    Join Date
    Jul 2012
    Posts
    4
    Rep Power
    0

    Question Autoboxing & Unboxing

    Hi i am new to java,so any one explain what in Autoboxing & Unboxing in java with a example....

    Thanks in advance

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    762
    Rep Power
    10

    Default Re: Autoboxing & Unboxing

    You can find the answer here: Autoboxing

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,712
    Rep Power
    15

    Default Re: Autoboxing & Unboxing

    The Object type (object-oriented programming) article in Wikipedia discusses the concepts generally. And Oracle's Tutorial has a page on Autoboxing and Unboxing as it relates to Java.

    Both are a good places to begin your investigation. Ask if you have specific problems understanding what you find.

  4. #4
    brianmanee is offline Member
    Join Date
    Sep 2014
    Posts
    3
    Rep Power
    0

    Default Re: Autoboxing & Unboxing

    Quote Originally Posted by asif_plz View Post
    Hi i am new to java,so any one explain what in Autoboxing & Unboxing in java with a example....

    Thanks in advance
    Autoboxing

    Autoboxing is the process of converting a primitive type data into its corresponding wrapper class object instance.

    Unboxing

    Unboxing is the process of converting a wrapper instance into a primitive type .

    When it required ?

    When a method is expecting a wrapper class object but the value that is passed as parameter is a primitive type. When primitive value assigned to wrapper class variable or reverse.

    Advantages

    No need to make object explicitly and wrap the value of primitive type.

    Disadvantage

    “Autoboxing” is too unexpected in its behavior and can easily result in difficult to recognize errors.

    Performance

    Autoboxing does create objects which is not clearly visible in the code. So when autoboxing occurs performance suffers.

    More about....Autoboxing and Unboxing in Java

    Brian

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    5,840
    Rep Power
    10

    Default Re: Autoboxing & Unboxing

    Please don't resurrect old threads. This one is four years old and should
    probably be closed.

    However, Welcome to the forum!

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Doubt in Unboxing error
    By learnjava1974 in forum New To Java
    Replies: 4
    Last Post: 07-04-2011, 11:55 PM
  2. Best Practice wrt Boxing / Unboxing
    By johnnyforeigner in forum Advanced Java
    Replies: 2
    Last Post: 06-05-2011, 12:10 PM
  3. Autoboxing
    By p0o0o0ya in forum New To Java
    Replies: 5
    Last Post: 02-03-2011, 07:04 AM
  4. autoboxing in action
    By Ahmed.Java in forum Java Software
    Replies: 1
    Last Post: 04-29-2010, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •