Cov txheej txheem:

Koj puas tuaj yeem ua array volatile?
Koj puas tuaj yeem ua array volatile?

Video: Koj puas tuaj yeem ua array volatile?

Video: Koj puas tuaj yeem ua array volatile?
Video: Машинное обучение с Python! Обучение, тестирование, разделение для оценки моделей 2024, Kaum ib hlis
Anonim

Lo lus teb yog, Yog, koj ua tau ib array (ob qho tib si primitive thiab reference type array e.g. ib int array thiab hlua array ) tsis hloov pauv hauv Java tab sis tsuas yog hloov mus rau kev siv taw tes rau ib qho array yuav pom tau rau txhua txoj xov, tsis yog tag nrho array.

Ib sab ntawm no, puas yog Java array xov zoo?

Java nco qauv xav txog txhua yam array element raws li qhov sib txawv. Tej zaum koj yuav muaj xov -kev ua tsis zoo ntawm qhov sib txawv xws li ib yam li lwm yam hloov pauv. Cov array nws tus kheej yog heev xov nyab xeeb . Koj tuaj yeem tau txais cov txiaj ntsig tsis raug, lossis txawm tias cov txiaj ntsig tsis pom zoo, lossis kev zam.

Qhov thib ob, dab tsi yog siv cov volatile hauv Java? Volatile Lo lus tseem ceeb hauv Java . Volatile lo lus tseem ceeb yog siv los hloov tus nqi ntawm qhov sib txawv ntawm cov xov sib txawv. Nws kuj yog siv ua kom cov chav kawm xov xwm nyab xeeb. Nws txhais tau tias ntau cov xov tuaj yeem siv ib txoj kev thiab piv txwv ntawm cov chav kawm tib lub sij hawm tsis muaj teeb meem.

Tib neeg kuj nug, cov khoom array khaws cia nyob qhov twg?

Thaum peb tshaj tawm ib array , chaw yog reserved nyob rau hauv lub cim xeeb ntawm lub computer rau lub array . Cov cov ntsiab lus ntawm array yog khaws cia nyob rau hauv cov chaw nco. Qhov tseem ceeb ntawm arrays yog tias array ntsiab yog ib txwm khaws cia nyob rau hauv qhov chaw nco sib law liag.

Koj txheeb qhov array li cas?

Ua tib zoo saib ntawm qhov piv txwv no:

  1. import java. siv. Arrays;
  2. Public class Sorting {
  3. pej xeem static void main (String args) {
  4. int array = {45, 12, 85, 32, 89, 39, 69, 44, 42, 1, 6, 8};
  5. Arrays. xaiv (array);
  6. Qhov system. tawm. println("Tag nrho Sorted: " + Arrays.
  7. int index = Arrays. binarySearch(array, 42);
  8. Qhov system. tawm.

Pom zoo: