Vim li cas peb siv wrapper class hauv Java nrog piv txwv?
Vim li cas peb siv wrapper class hauv Java nrog piv txwv?

Video: Vim li cas peb siv wrapper class hauv Java nrog piv txwv?

Video: Vim li cas peb siv wrapper class hauv Java nrog piv txwv?
Video: Sib Pauv Zog By Huab Vwj; Celesna Lor Ft Leekong Xiong; Nuj xeem 2024, Kaum ib hlis
Anonim

Qhov zoo ntawm Java Wrapper Class

Lawv siv los hloov cov ntaub ntawv keeb kwm yav dhau los rau hauv cov khoom (Objects yog xav tau thaum peb yuav tsum dhau qhov kev sib cav hauv txoj kev muab). util muaj chav kawm uas tsuas yog tuav cov khoom, yog li nws yuav pab tau qhov no thiab. Cov Txheej Txheem Cov Ntaub Ntawv khaws cov khoom thiab cov ntaub ntawv qub qub xwb.

Tom qab ntawd, ib tug kuj yuav nug, dab tsi yog qhov tseem ceeb ntawm chav kawm wrapper hauv Java?

Cov chav kawm Wrapper yog siv los hloov tej yam ntaub ntawv rau hauv ib yam khoom. Cov ntaub ntawv keeb kwm yav dhau los tsis yog khoom; lawv tsis zwm rau ib qho twg chav kawm ; lawv txhais ua lus xwb. Qee zaum, nws yuav tsum tau hloov cov ntaub ntawv hom rau hauv cov khoom hauv Java lus.

Tom qab ntawd, lo lus nug yog, dab tsi yog wrappers hauv Java? Cov ntaub qhwv Cov chav kawm hauv Java . A Cov ntaub qhwv chav kawm yog ib chav kawm uas nws cov khoom qhwv lossis muaj cov ntaub ntawv tseem ceeb. Hauv lwm lo lus, peb tuaj yeem qhwv tus nqi qub rau hauv a ntaub qhwv chav kawm khoom. Xav tau ntawm Cov ntaub qhwv Cov chav kawm. Lawv hloov cov ntaub ntawv qub qub rau hauv cov khoom.

Yog li ntawd, cov chav kawm wrapper muab ob qho piv txwv li cas?

Cov yim cov ntaub ntawv keeb kwm yav dhau los byte, luv, int, ntev, ntab, ob npaug, char thiab boolean tsis yog khoom, Cov chav kawm Wrapper yog siv los hloov cov ntaub ntawv keeb kwm yav dhau los rau hauv cov khoom, xws li int rau Integer thiab lwm yam.

Wrapper chav kawm hauv Java.

Keeb kwm Wrapper chav kawm
luv Luv luv
int Tus lej
ntev Ntev
ntab ntab

Peb puas tuaj yeem tsim peb tus kheej wrapper chav kawm hauv Java?

Kev cai Wrapper chav kawm hauv Java Java Wrapper chav kawm qhwv cov ntaub ntawv primitive hom, uas yog vim li cas nws yog hu ua cov chav kawm wrapper . Peb ua tau kuj tsim a chav kawm uas wraps hom ntaub ntawv primitive. Yog li ntawd, peb tuaj yeem tsim kev cai wrapper chav kawm hauv Java.

Pom zoo: