Autoboxing ใน java 5.0

posted on 09 Feb 2005 23:32 by somkiat

Autoboxing

Autoboxing, introduced in Java 5, is the automatic conversion that Java makes between the primitive (basic) types and their corresponding object wrapper classes (eg, int and Integer, boolean and Boolean, etc). This sugar coating the avoids the tedious and hard-to-read casting typically required by Java Collections, which can not be used with primitive types.

Example

With AutoboxingWithout Autoboxing
int i;
Integer j;
i = 1;
j = 2;
i = j;
j = i;
int i;
Integer j;
i = 1;
j = new Integer(2);
i = j.valueOf();
j = new Integer(i);

Prefer primitive types

Use the primitive types where there is no need for objects for two reasons.

  1. Primitive types will not be slower than their corresponding wrapper types, and may be a lot faster.
  2. There can be some unexepected behavior involving == (compare references) and .equals() (compare values). See the reference below for examples.

References

Comment

Comment:

Tweet

chanel bags,http://www.chanelhandbags.net.in/softball bats,http://www.cheap-baseballbats.net/
nfl jerseys,http://www.cheapjerseys.us.org/
nfl jerseys,http://www.cheap-jerseys.us.org/
cheap jordan shoes,http://www.cheap-jordans.net/
michael kors,http://www.cheapmichaelkors.us.org/
nike shoes,http://www.cheap-nike-shoes.net/
oakley sunglasses,http://www.cheapoakley.us.org/
oakley sunglasses,http://www.cheapoakleysunglasses.ar.com/
oakley sunglasses,http://www.cheap-oakleysunglasses.in.net/
ray ban sunglasses,http://www.cheaprayban.com.co/
discount shoes,http://www.cheapshoes.com.co/
uggs outlet,http://www.cheap-uggboots.in.net/
dre beats,http://www.beatsbydrdre.co.com/
beats audio,http://www.beatsbydre.com.co/
beats audio,http://www.beats-by-dre.com.co/
beats audio,http://www.beats-headphone.in.net/
bebe clothing,http://www.bebeclothing.net/
bottega veneta,http://www.bottega.us/
burberry,http://www.burberrycanada.ca/
burberry outlet,http://www.burberry-handbags.us.org/
burberry outlet online,http://www.burberryoutlet.club/
burberry outlet online,http://www.burberryoutlet.me.uk/
burberry outlet,http://www.burberryoutletonline.ar.com/
burberry outlet online,http://www.burberrys-outlet.in.net/
burberry outlet,http://www.burberrys-outletonline.in.net/
calvin klein underwear,http://www.calvinklein.co.com/
celine bags,http://www.celinebags.org/
chanel sunglasses,http://www.chanel-bags.com.co/
polo ralph lauren,http://www.polo-outlets.com.co/
ralph lauren outlet,http://www.poloralphlaurenoutlet.net.co/
prada outlet,http://www.pradahandbags.com.co/
prada outlet,http://www.pradahandbags.net.co/
prada handbags,http://www.pradaoutlet.com.co/
prada outlet,http://www.pradashoes.com.co/
ralph lauren,http://www.ralph-lauren.ca/
ralph lauren,http://www.ralph-lauren.com.au/
ralph lauren uk,http://www.ralph-lauren.org.uk/
ralph lauren outlet,http://www.ralphlaurenepolo.com/
burberry,http://burberry.outletnow.org/
christian louboutin outlet,http://christianlouboutin.outlet-shoes.net/
tory burch sale,http://toryburch.salesandals.net/
abercrombie,http://www.abercrombie-and-fitch.ca/
abercrombie and fitch,http://www.abercrombieand-fitch.com.co/
abercrombie fitch,http://www.abercrombie-and-fitch.us.com/
abercrombie and fitch,http://www.abercrombiefitch.us.com/
abercrombie,http://www.abercrombie-kids.us.com/
adidas,http://www.adidas--canada.ca/
nike huarache,http://www.air-huarache.co.uk/
retro jordans,http://www.airjordans.us/
jordan release dates 2015,http://www.airjordanshoes2015.com/
air max 2014,http://www.airmax-2015.org/
air max,http://www.airmax-90.org/
babyliss pro,http://www.babyliss.us.org/
barbour jackets sale,http://www.barbour-factory.com/
barbour mens jackets,http://www.barbour-jacketsoutlet.com/
basketball shoes,http://www.basketballshoes.com.co/
bcbg max,http://www.bcbgdresses.net/
bcbg max,http://www.bcbg-max-azria.ca/
flat iron,http://www.chiflatiron.net.co/
louboutin,http://www.christian--louboutin.in.net/
louboutin shoes,http://www.christianlouboutin.org.uk/
louboutin outlet,http://www.christianlouboutinoutlet.net.co/
christian louboutin,http://www.christianlouboutinshoes.ar.com/
christian louboutin,http://www.christian-louboutin-shoes.ca/
louboutin shoes,http://www.christianlouboutinshoes.jp.net/
coach factory outlet online,http://www.coachfactory-outlet.co.com/
coach factory outlet,http://www.coachfactory-outlet-online.in.net/
coach purses,http://www.coach-handbags.com.co/
coach outlet,http://www.coachoutlet-online.com.co/
coach outlet,http://www.coachoutletstore.net.co/
coach outlet,http://www.coachoutletstore-online.com.co/
coco chanel,http://www.coco-chanelbags.com.co/
converse shoes,http://www.converse.net.co/
converse,http://www.converses-shoes.net/
handbags outlet,http://www.designerhandbagsoutlet.com.co/
ed hardy,http://www.edhardy.us.org/
glasses online,http://www.eyeglassesonline.us.org/
glasses frames,http://www.eyeglassframes.us.org/
boutique clothing,http://www.fashion-clothing.us.org/
salvatore ferragamo,http://www.ferragamo.com.co/
ferragamo,http://www.ferragamoshoes.net/
straightener,http://www.ghdhairstraightener.com.co/
giuseppe zanotti,http://www.giuseppezanotti.com.co/
gucci handbags,http://www.guccihandbags.net.co/
gucci outlet,http://www.gucci-outlet.biz/
gucci sale,http://www.gucci-outletsale.in.net/
gucci outlet,http://www.guccishoes.com.co/
gucci outlet,http://www.guccishoes.in.net/
gucci outlet,http://www.guccishoes.us.org/
gucci,http://www.gucci-uk.me.uk/
purses and handbags,http://www.handbagsoutlet.com.co/
harrods,http://www.harrods-london.co.uk/
katespade,http://www.kate-spade.net.co/
kate spade,http://www.katespade-outlet.net.co/
levi's jeans,http://www.levisjeans.com.co/
longchamp outlet,http://www.longchamp.com.co/
longchamp handbags,http://www.longchamp.us.org/
longchamp,http://www.longchamp-handbags.us.com/
longchamp,http://www.longchampoutlet.com.co/
christian louboutin,http://www.louboutin.jp.net/
louis vuitton,http://www.louisvuitton.jp.net/
louis vuitton,http://www.louis--vuitton.org.uk/
louis vuitton outlet,http://www.louisvuitton.so/
louis vuitton outlet,http://www.louisvuittonas.com/
louis vuitton,http://www.louis-vuitton-australia.com.au/
louis vuitton outlet,http://www.louis-vuittonblackfriday.com/
louis vuitton,http://www.louisvuitton-outlet.com.co/
louis vuitton,http://www.louis-vuittonoutletcanada.ca/