Cov txheej txheem:

Dab tsi yog qhov sib piv hauv Java collections?
Dab tsi yog qhov sib piv hauv Java collections?

Video: Dab tsi yog qhov sib piv hauv Java collections?

Video: Dab tsi yog qhov sib piv hauv Java collections?
Video: G-Shock Magma Ocean Collection Comparison | GPRB1000 Rangeman | GWF1035 Frogman | MTGB1000 2024, Kaum ib hlis
Anonim

Muab piv Interface - Java Collections . Hauv Java , Muab piv interface yog siv los txiav txim (xaiv) cov khoom hauv sau nyob rau hauv koj tus kheej txoj kev. Nws muab koj lub peev xwm los txiav txim seb cov khoom yuav raug txheeb xyuas thiab khaws cia li cas hauv sau thiab daim ntawv qhia. Muab piv Interface txhais piv () txoj kev. Txoj kev no muaj ob qhov kev txwv.

Yog li ntawd, tus sib piv ua Java li cas?

Java Comparator yog ib qho interface rau sorting Java khoom. Invoked los ntawm " java ua . tus piv ,” Java Comparator piv ob Java cov khoom nyob rau hauv ib tug "sib piv (Object 01, Object 02)" hom. Siv cov txheej txheem configurable, Java Comparator tuaj yeem sib piv cov khoom kom rov qab tau tus lej raws li qhov zoo, sib npaug lossis tsis zoo sib piv.

Ib tug kuj yuav nug, lub pob twg tus piv cov lus dag? Muab piv interface lus dag hauv java. siv pob . Nws yog siv los ua cov khoom luv luv hauv kev txiav txim siab xws li txheeb ob yam khoom raws li cov txheej txheem tau hais tseg.

Ib yam li ntawd, qhov sib txawv ntawm Java sau thiab Java collections yog dab tsi?

Major qhov sib txawv ntawm Collection thiab Kev sau yog Sau yog ib qho interface thiab Kev sau yog chav kawm. Sau yog lub hauv paus interface rau cov npe teev thiab kab. Sau yog lub hauv paus interface rau Sau, Teeb thiab Queue. Sau yog lub hauv paus theem interface ntawm lub Java Collection Lub moj khaum.

Yuav ua li cas koj siv tus sib piv hauv Java?

Siv Comparator

  1. Tsim ib chav kawm uas siv Comparator (thiab yog li qhov sib piv () txoj kev uas ua haujlwm yav dhau los ua los ntawm kev sib pivTo()).
  2. Ua ib qho piv txwv ntawm Comparator class.
  3. Hu rau tus txheej txheem overloaded sort(), muab nws ob lub npe thiab cov piv txwv ntawm chav kawm uas siv Comparator.

Pom zoo: