Java pawg yog dab tsi?
Java pawg yog dab tsi?

Video: Java pawg yog dab tsi?

Video: Java pawg yog dab tsi?
Video: Yog hmoov dab tsi - Gao Nou Kue ft. Mang Vang (Official Music Video) New song 2020 2024, Kaum ib hlis
Anonim

Java muab ib hom khoom inbuilt hu ua Pob . Nws yog ib qho kev sau uas yog raws li qhov kawg hauv thawj qhov tawm (LIFO) txoj cai. Ntawm Creation, a pawg yog khoob. Nws txuas Vector chav kawm nrog tsib txoj hauv kev uas tso cai rau tus vector kom raug kho raws li a pawg . Object push (Object element): Pushes ib lub caij rau saum lub pawg.

Ib yam li ntawd, Java puas muaj pawg pawg?

Stack Class hauv Java . Java Collection moj khaum muab ib stack chav kawm uas qauv thiab siv Pob cov ntaub ntawv qauv. Cov chav kawm yog raws li lub hauv paus ntsiab lus ntawm qhov kawg-hauv-thawj-tawm. Ntxiv rau qhov yooj yim thawb thiab pop ua haujlwm, lub chav kawm muab peb txoj haujlwm ntxiv ntawm khoob, tshawb nrhiav thiab peek.

Tsis tas li ntawd, dab tsi yog kab hauv Java? Java Queue yog ib tug interface muaj nyob rau hauv java ua . siv pob thiab txuas ntxiv java ua . siv. Ib yam li Java Sau npe, Java Queue yog ib qho kev sau ntawm cov khoom xaj (lossis cov khoom) tab sis nws ua tau ntxig thiab tshem tawm cov haujlwm sib txawv. Peb tuaj yeem siv tau Daim ntawv khaws cov khoom ua ntej ua cov khoom ntawd.

Khaws qhov no hauv kev pom, dab tsi yog pawg thiab kab hauv Java?

Nws muaj chav kawm hu ua java ua . siv. Tam sim no cia saib qhov sib txawv ntawm Pawg thiab Queue cov ntaub ntawv qauv hauv Java : 1) Thawj thiab loj sib txawv ntawm Pawg thiab Queue cov ntaub ntawv qauv yog tias Pob yog LIFO (Last In First Out) cov ntaub ntawv qauv thaum Daim ntawv yog FIFO (First In First out) cov ntaub ntawv qauv.

Koj tsim ib pawg li cas?

Muaj ob txoj hauv kev los siv a pawg : Siv array. Siv cov npe txuas.

Feem ntau peb cov haujlwm hauv qab no tau ua hauv pawg:

  1. Push: Ntxiv ib yam khoom hauv pawg.
  2. Pop: Tshem tawm ib yam khoom los ntawm pawg.
  3. Peek lossis Top: Rov qab cov ntsiab lus saum toj kawg nkaus ntawm pawg.

Pom zoo: