Dab tsi yog qhov zoo li qub hauv Apex?
Dab tsi yog qhov zoo li qub hauv Apex?

Video: Dab tsi yog qhov zoo li qub hauv Apex?

Video: Dab tsi yog qhov zoo li qub hauv Apex?
Video: yog hmoov dab tsi. Zoo Xyooj (cover) 2024, Kaum ib hlis
Anonim

A zoo li qub txoj kev lossis qhov sib txawv tsis tas yuav muaj qhov piv txwv ntawm chav kawm thiaj li khiav. Ua ntej qhov khoom ntawm chav kawm raug tsim, tag nrho zoo li qub cov tswv cuab sib txawv hauv chav kawm yog pib, thiab tag nrho zoo li qub pib code blocks raug tua. A zoo li qub variable yog zoo li qub tsuas yog nyob rau hauv lub Scope ntawm lub Apex kev pauv nyiaj.

Tsis tas li ntawd, qhov zoo li qub txhais li cas hauv Apex?

zoo li qub [stat-ik] (adjective): tsis muaj zog, kev loj hlob, los yog tseem ceeb. Static yog ib tshwj xeeb, feem ntau siv lo lus hloov kho hauv Apex uas tseem ceeb txaus kom tau txais nws tus kheej ncej. Static sib txawv yog variables uas zwm rau ib chav kawm tag nrho, tsis yog ib yam khoom ntawm ib chav kawm.

Tsis tas li ntawd, vim li cas cov kev sim ntsuas zoo li qub hauv Salesforce? Test Methods yog static vim koj tsis hu lub kev sim meej meej thaum koj khiav ib chav rau kev tua. A txoj kev zoo li qub tsis xav tau ib qho piv txwv ntawm chav kawm thiaj li khiav tau. Lawv tau tsim nrog txhua yam khoom instantiated los ntawm cov chav kawm uas lawv tau tshaj tawm. Kos kom daws tau yog tias qhov no pab tau.

Kuj nug, dab tsi yog qhov txawv ntawm qhov zoo li qub thiab tsis zoo li qub hauv Apex?

- A static variable yog qhia ntawm tag nrho cov piv txwv ntawm ib chav kawm. - A tsis yog - static variable tshwj xeeb rau ib qho piv txwv ntawm chav kawm ntawd. Ej: A static variable tuaj yeem sib koom los ntawm txhua tus neeg siv rau qhov kev khiav haujlwm tam sim no.

Dab tsi yog qhov txawv ntawm tus kheej static variable?

A pej xeem variable yog nkag tau los ntawm txhua qhov chaw (zoo, qhov twg hauv chav kawm nkag mus tau). A tus kheej hloov pauv tsuas yog siv tau hauv chav kawm xwb. A static variable belongs rau chav kawm es tsis yog rau ib qho piv txwv ntawm chav kawm.

Pom zoo: