Java class member yog dab tsi?
Java class member yog dab tsi?

Video: Java class member yog dab tsi?

Video: Java class member yog dab tsi?
Video: StringBuffer Class & Methods in Java with Example 2024, Kaum ib hlis
Anonim

Class Member Access Modifiers

Cheebtsam ntawm a chav kawm , xws li nws cov piv txwv variables los yog txoj kev hu ua cov tswv cuab ntawm a chav kawm los yog cov tub kawm . A cov tub kawm tau tshaj tawm nrog rau kev hloov kho kom paub meej tias nws nkag los ntawm lwm tus li cas chav kawm hauv Java.

Tsis tas li ntawd, ib tug tswv cuab ntawm chav kawm yog dab tsi?

Cov tub kawm , hauv C#, yog cov cov tswv cuab ntawm ib chav kawm uas sawv cev rau cov ntaub ntawv thiab tus cwj pwm ntawm a chav kawm . Cov tub kawm yog cov tswv cuab tshaj tawm nyob rau hauv lub chav kawm thiab tag nrho cov (tsis suav cov neeg tsim kho thiab cov destructors) tshaj tawm nyob rau hauv tag nrho chav kawm nyob rau hauv nws qhov qub txeeg qub teg hierarchy.

Tom qab, lo lus nug yog, dab tsi yog Java tus tswv cuab ua haujlwm? Kev tshaj tawm. A kev ua tswv cuab ntawm chav kawm yog a muaj nuj nqi uas muaj nws cov lus txhais lossis nws cov qauv hauv chav kawm txhais zoo li lwm yam sib txawv. Nws ua haujlwm ntawm txhua yam khoom ntawm chav kawm uas nws yog a tus tswv cuab , thiab muaj kev nkag mus rau tag nrho cov cov tswv cuab ntawm ib chav kawm rau cov khoom ntawd.

Ib yam li ntawd, nws tau nug, dab tsi yog chav kawm sib txawv hauv Java?

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. Nco ntsoov tias hauv Java , cov ntsiab lus "field" thiab " sib txawv " siv interchangeably rau cov tswv cuab sib txawv.

Cov tswv cuab txoj hauv kev yog dab tsi?

Tus tswv cuab yog ib lub ntsiab lus dav dav uas suav nrog cov hauv qab no: Constructors, Cov txheej txheem , Properties, Fields, and Events. A txoj kev yog ib txoj haujlwm uas cuam tshuam nrog ib qho piv txwv ntawm chav kawm lossis chav kawm zoo li qub.

Pom zoo: