Skip Navigation Links



Auto boxing and Unboxing in Java – Be careful while using

Author : Javin Paul      Blog :TIBCO RV FIX PROTOCOL JAVA TUTORIAL      Date: 7/18/2012 12:55:00 PM


Auto boxing in Java
Auto boxing and un-boxing is introduced in Java 1.5 to automatically convert primitive type into boxed primitive( Object or Wrapper class) in Java. If you have been using Collections like HashMap or ArrayList before Java 1.5 then you are familiar with the issue that you can not directly put primitives into Collections, instead you first need to convert them in to Object only then you can put them into Collections. Wrapper class like Integer, Double and Boolean helps for converting primitive to Object but that clutter the code. With the introduction of auto boxing and unboxing in Java this primitive to object conversion happens automatically by Java compiler which makes code more readable. But auto boxing and unboxing comes with certain caveats which needs to be understood before using them in production code and it becomes even more important because they are automatic and can create subtle bugs if you are not sure when auto boxing occurs and when auto unboxing happens. This is my fifth article on features introduced in Java 5 after my post on Java EnumHow Generics works in Java and varargs example. In this Java tutorial we will see: What is auto boxing and unboxing?  When auto boxing and unboxing occurs in Java? and things to remember while dealing with primitives and objects in Java with code examples.
Read more »

Bloggers

active bloggers in the last 24 hrs. Number shown in the bracket represents number of posts published in past 24 hrs,


other authors(79)

Firoze Shakir Photographerno1(6)

Sakshi Garg(4)

Anubhav Sharma(2)

churumuri(2)

Claude Renault(2)

Fidarose Isha(2)

Harimohan(2)

Kalyan P(2)

Mythreyi(2)

N.GURURAJ.(2)

R.D. Bhalekar(2)

sumana Mukhopadhyay(2)

the blogger formerly known as sansmerci(2)

Vashi Chandiramani(2)

Vasudev Ram(2)

- Sugar Cube -(1)

Aarthi(1)

aburman(1)

Ajay Shah(1)

aKuma(1)

Amar Ashok Jajoo(1)

Amita(1)

Anirudh(1)

ankush samant(1)

anouradha bakshi(1)

Ashwini Kumar(1)

Atanu Ghosal(1)

bhuji(1)

Bhushavali N(1)

Bhushavali N(1)

BUTTERFLIES OF TIME(1)

Cheena Chopra(1)

Creative Rumblings(1)

Cynical(1)

Debolina Raja Gupta(1)

Debolina Raja Gupta(1)

Deepak(1)

Deeps(1)

Dew(1)

Divya Kudua(1)

Dream Killers 11(1)

ephemeral desires(1)

Familycook(1)

G Angela(1)

Gaurav(1)

Gautam Anand(1)

Gautam S Brahma(1)

Govind Kumar(1)

Hamsamalini Chandrasekaran(1)

harish p i(1)

Hawk Eye(1)

Hindi CinemaBlog(1)

Indrani(1)

IS(1)

Iti(1)

Jabberwock(1)

Javin Paul(1)

jquerybyexample(1)

Kalpana Misra(1)

KALVA(1)

Krishna Rao(1)

Krithi Karthi(1)

Lakshmi(1)

liveonimpulse(1)

Mahendra Arya(1)

Meena(1)

mêlée(1)

mervin anto(1)

momofrs(1)

MY EXPRIMENT(1)

Nagendra Bharathi(1)

Nethra A(1)

Nikhil Sheth(1)

nimisha mistry(1)

Nisa Homey(1)

Nisheeth Ranjan(1)

Nupur(1)

Paritosh Anand(1)

Patricia Torres(1)

pinksocks(1)

pixie(1)

Piya Jayarajan(1)

Pradeep Chakraborty(1)

Priya(1)

Priyas Feast(1)

Priyasha(1)

R Sudhir Kumar(1)

Richa Singh(1)

Rinaya(1)

Ritesh Agarwal(1)

Ritz..(1)

Sabina Fatima Hussain(1)

Sangeetha M(1)

Santanu(1)

sathish kumar(1)

share consultants(1)

sheetal paliwal(1)

Shweta Ganesh Kumar(1)

soraya nulliah(1)

Spiritual Sherpa(1)

Srinivasan Sampathkumar(1)

Sriram Khé(1)

Srishti Aishwarya(1)

Srivalli(1)

sulagna ™(1)

Umasree(1)

Varsha(1)

vinu(1)

VJ Sharma(1)

Zardy(1)


garland of Languages of India
an amalgamation of the diversified traditions
gracefully presented with novelty
http://www.haaram.com