Can java enum be serializable?

Cov txheej txheem:

Can java enum be serializable?
Can java enum be serializable?
Anonim

Vim enums tau txais Serializable (saib Javadoc API cov ntaub ntawv rau Enum), tsis tas yuav tsum tau hais meej ntxiv cov lus "ua haujlwm Serializable" raws li kev tshaj tawm enum. Thaum qhov no raug tshem tawm, daim ntawv qhia ntshuam rau java. io ib. Serializable interface kuj raug tshem tawm.

Puas yog tag nrho cov chav kawm Java serializable?

Tsuas Cov Chav Kawm Uas Siv Tau Serializable tuaj yeem SerializedThaum ib chav kawm siv Serializable interface, tag nrho nws cov chav kawm sub-serializable thiab. Tab sis thaum ib yam khoom muaj kev siv rau lwm yam khoom, cov khoom no yuav tsum siv Serializable interface cais.

Can enum muaj cov cim tshwj xeeb Java?

Enum constants yuav tsum yog Java tus lej siv tau. Koj tuaj yeem override toString yog tias koj xav kom lawv nthuav tawm txawv.

Is HashSet serializable Java?

2 Teb. HashSet yog serializable [Cov ntaub ntawv] tsuav yog tag nrho cov khoom nws muaj yog serializable, yog li koj yuav tsum xyuas kom meej tias Chaw Nyob Chav Kawm yog serializable.

Can enum inherit Java?

Java enum yog ib yam ntawm cov khawv koob compiler. Hauv byte code, ib qho enum yog sawv cev raws li chav kawm uas txuas ntxiv cov chav kawm paub daws teeb java. … Enum thiab muaj ntau tus tswv cuab zoo li qub. Yog li ntawd, enum tsis tuaj yeem ncua lwm chav lossis enum: tsis muaj ntau yam qub txeeg qub teg.

Pom zoo: