Dab tsi yog kev sib tshuam hauv Java?
Dab tsi yog kev sib tshuam hauv Java?

Video: Dab tsi yog kev sib tshuam hauv Java?

Video: Dab tsi yog kev sib tshuam hauv Java?
Video: Ib sim nkauj nraug tsis sib tau-maiv xis xyooj nkauj tawm tshiab 2022 2024, Kaum ib hlis
Anonim

Kawm nrhiav tus kev sib tshuam nruab nrab ntawm ob arrays hauv Java siv HashSet chav kawm. Ib kev sib tshuam yog ib pawg ntawm cov khoom uas muaj nyob rau hauv ob pawg sib txawv. Siv retainAll() txoj kev khaws cia tsuas yog cov ntsiab lus uas muaj nyob rau hauv ob array.

Ib sab ntawm no, dab tsi yog opposite ntawm kev sib tshuam?

Tsis yog ntawm no ua rau ib tug xav txog kev sib tshuam , nyob rau hauv lub siab hais tias lawv xav tias "nws yog tus rov qab ntawm ib kev sib tshuam ". Hauv lej, ob kab uas tsis yog sib tshuam yog los ntawm txhais parallel. Ob yam khoom uas tsis yog sib tshuam yog tsis sib tshuam.

Tom qab, lo lus nug yog, dab tsi yog kev siv retainAll txoj hauv Java? Cov khaws tag nrho () txoj kev ntawm ArrayList yog siv tshem tawm tag nrho cov array daim ntawv teev cov ntsiab lus uas tsis muaj nyob rau hauv cov kev sau sau los yog khaws cia tag nrho cov ntsiab lus sib xws hauv ArrayList tam sim no uas phim tag nrho cov ntsiab lus los ntawm Cov Ntawv Sau Sau tau dhau los ua qhov ntsuas rau txoj kev.

Ib yam li ntawd, koj tuaj yeem nug, qhov kev sib tshuam ntawm ob lub array yog dab tsi?

Kev sib tshuam txhais tau hais tias muaj cov ntsiab lus hauv qhov muab ob arrays . Piv txwv li, A = [1, 4, 3, 2, 5, 6] B = [3, 2, 1, 5, 6, 7, 8, 10] kev sib tshuam ntawm A thiab B yog [1, 3, 2, 5, 6]. Raws li muab arrays yog unsorted, txheeb ib qho ntawm arrays , nyiam qhov loj dua. Tom qab ntawd tshawb xyuas txhua lub ntsiab lus ntawm lwm tus array nyob rau hauv lub sorted array siv binary nrhiav.

Union hauv Java yog dab tsi?

Kawm nrhiav tus lub koomhaum nruab nrab ntawm ob arrays hauv Java siv HashSet chav kawm. Hauv kev teeb tsa txoj kev xav, lub lub koomhaum (tus sau los ntawm U) ntawm ib qho kev sau ntawm cov khoom yog cov txheej txheem ntawm tag nrho cov khoom hauv kev sau. Piv txwv li, lub lub koomhaum ntawm ob pawg A thiab B yog cov txheej txheem ntawm tag nrho cov ntsiab lus uas yog nyob rau hauv A, lossis hauv B, lossis hauv A thiab B.

Pom zoo: