Vim li cas cov kev hloov pauv hloov pauv tsis yog serialized?
Vim li cas cov kev hloov pauv hloov pauv tsis yog serialized?

Video: Vim li cas cov kev hloov pauv hloov pauv tsis yog serialized?

Video: Vim li cas cov kev hloov pauv hloov pauv tsis yog serialized?
Video: Pua xav paub yog vim li cas koj lub neej thiaj tsis hloov pauv....?(1/11/2020) 2024, Kaum ib hlis
Anonim

tsis tu ncua yog Java lo lus tseem ceeb uas cim cov tswv cuab sib txawv tsis ua serialized thaum nws yog persisted rau kwj ntawm bytes. Thaum ib yam khoom raug xa mus los ntawm lub network, cov khoom yuav tsum yog ' serialized '. Serialization converts cov khoom lub xeev rau serial bytes.

Raws li kev sib raug zoo, tuaj yeem hloov pauv hloov pauv tau serialized?

A hloov pauv hloov pauv yog a sib txawv uas ua tau tsis yog serialized . Raws li Java Language Specification [jls-8.3. 1.3]-“ Hloov pauv tej zaum yuav raug cim tsis tu ncua los qhia tias lawv tsis yog ib feem ntawm lub xeev tsis tu ncua ntawm ib yam khoom."

Ib sab saum toj, vim li cas peb thiaj xav tau cov hloov pauv hloov pauv hauv Java? transient yog a sib txawv modifier siv nyob rau hauv serialization. Thaum lub sij hawm serialization, yog peb tsis txhob xav txuag tus nqi ntawm ib qho tshwj xeeb sib txawv nyob rau hauv ib cov ntaub ntawv, ces peb siv tsis tu ncua lo lus tseem ceeb. Thaum JVM tuaj hla tsis tu ncua lo lus tseem ceeb, nws ignores thawj tus nqi ntawm tus sib txawv thiab txuag tus nqi pib ntawm qhov ntawd sib txawv hom ntaub ntawv.

Dhau li ntawm no, yog vim li cas static thiab hloov pauv hloov tsis tau serialized?

Static Variables : Cov variables tsis serialized , Yog li thaum deserialization static variable tus nqi yuav thauj khoom los ntawm chav kawm. Hloov pauv hloov pauv : cov hloov pauv hloov pauv tsis yog serialized , yog li thaum deserialization cov sib txawv yuav pib nrog cov txiaj ntsig zoo sib xws (ex: rau cov khoom null, int 0).

Vim li cas static teb tsis serialized?

Static Hloov pauv. Static variables belongs rau ib chav kawm thiab tsis yog rau ib qho piv txwv ntawm tus kheej. Lub tswvyim ntawm serialization muaj kev txhawj xeeb txog qhov khoom tam sim no. Tsuas yog cov ntaub ntawv cuam tshuam nrog ib qho piv txwv tshwj xeeb ntawm chav kawm yog serialized , yog li ntawd zoo li qub tus tswv cuab teb raug ignored thaum lub sij hawm serialization.

Pom zoo: