Dab tsi yog qhov sib txawv hauv chav kawm hu ua?
Dab tsi yog qhov sib txawv hauv chav kawm hu ua?

Video: Dab tsi yog qhov sib txawv hauv chav kawm hu ua?

Video: Dab tsi yog qhov sib txawv hauv chav kawm hu ua?
Video: Koj Hais Dab Tsi?/Suabci Kwm & Ab Meej Ham/Official MV 2023 2024, Kaum ib hlis
Anonim

Hauv chav kawm -raws li cov lus, cov no yog qhov txawv ntawm ob hom: yog tias tsuas muaj ib daim qauv ntawm cov ntawv sib txawv koom nrog txhua qhov piv txwv ntawm cov chav kawm , yog hu ua a chav kawm sib txawv los yog tus tswv cuab zoo li qub sib txawv ; hos yog hais tias txhua yam ntawm cov chav kawm nws muaj nws tus kheej daim ntawv sib txawv , cov sib txawv yog hu ua ib qho piv txwv sib txawv.

Yog li, dab tsi yog qhov sib txawv ntawm chav kawm?

Nyob rau hauv object-oriented programming nrog chav kawm , a chav kawm sib txawv yog ib qho sib txawv tshaj tawm nrog tus hloov kho zoo li qub uas muaj ib daim ntawv luam tawm, txawm tias muaj pes tsawg zaus ntawm chav kawm muaj. Nws yog ib hom tshwj xeeb ntawm chav kawm attribute (los yog chav kawm vaj tse, teb, los yog cov ntaub ntawv tus tswv cuab).

Ib yam li ntawd, qhov piv txwv thiab chav kawm hloov pauv yog dab tsi? Ib qho piv txwv sib txawv yog zoo ib yam li chav kawm sib txawv. Ib qho piv txwv sib txawv yog qhov sib txawv uas tau tshaj tawm hauv chav kawm tab sis sab nraum tus tsim thiab tus qauv / kev ua haujlwm. Piv txwv variables raug tsim thaum ib khoom yog instantiated, thiab nkag tau mus rau txhua txoj kev, tus tsim thiab thaiv hauv chav kawm.

Raws li txoj cai, dab tsi yog qhov sib txawv hauv chav kawm hu ua Java?

Java muab peb hom sib txawv . Chav kawm variable − Chav kawm variable kuj hu ua static sib txawv tau tshaj tawm nrog lo lus tseem ceeb zoo li qub hauv a chav kawm , tab sis sab nraum ib txoj kev, constructor lossis block. Thaum qhov chaw raug faib rau ib qho khoom hauv lub heap, ib lub qhov rau txhua qhov piv txwv sib txawv tus nqi tsim.

Dab tsi yog chav kawm thiab khoom siv?

Chav kawm piv khoom A chav kawm yog template rau khoom . A chav kawm txhais khoom cov khoom suav nrog cov khoom siv tau zoo, thiab tus nqi pib. A chav kawm kuj piav khoom tus cwj pwm. Ib khoom yog ib tug tswv cuab los yog "piv txwv" ntawm a chav kawm.

Pom zoo: