Cov txheej txheem:

Dab tsi yog qhov tseem ceeb ntawm cov ntaub ntawv keeb kwm yav dhau los hom int thiab ntab?
Dab tsi yog qhov tseem ceeb ntawm cov ntaub ntawv keeb kwm yav dhau los hom int thiab ntab?

Video: Dab tsi yog qhov tseem ceeb ntawm cov ntaub ntawv keeb kwm yav dhau los hom int thiab ntab?

Video: Dab tsi yog qhov tseem ceeb ntawm cov ntaub ntawv keeb kwm yav dhau los hom int thiab ntab?
Video: 6 Nqi Lus Qhia Kev Ua neej ( leej twg mloog lub neej yuav zoo tuaj) 2024, Hlis ntuj nqeg
Anonim

Default Values of Java's Primitive Types

Hom Default tus nqi
int 0
ntev 0
ntab 0,0f ua
ob npaug 0.0d ib

Ib yam li ntawd, nws tau nug, dab tsi yog tus nqi pib ntawm INT?

int : Los ntawm ua ntej , cov int hom ntaub ntawv yog ib tug 32-ntsis kos npe ob lub complement integer, uas muaj qhov tsawg kawg nkaus tus nqi ntawm -231 thiab qhov siab tshaj plaws tus nqi ntawm 231-1.

Tsis tas li ntawd, hom twg tseem ceeb tuaj yeem tuav tus nqi loj tshaj plaws? Nyob rau hauv IEEE 754 floating-point tus lej tus qauv rau 32 ntsis lus, lub loj tshaj plaws tus lej zoo li ntawd ua tau 1.111111111111111111111111 x 2127 3.40282347 x 1038.

Tus lej.

Hom Loj Ntau yam
byte 8bit ib -128.. 127
luv 16 bits -32, 768.. 32, 767
int 32bit ib -2, 147, 483, 648.. 2, 147, 483, 647

Tsuas yog li ntawd, dab tsi yog qhov tseem ceeb ntawm ntau hom primitive?

Default Value of Data Types in Java:

Hom ntaub ntawv Default Value (rau cov teb)
ntev 0 l xav
ntab 0,0f ua
ob npaug 0.0d ib
char 'u0000'

Dab tsi yog cov ntaub ntawv tseem ceeb thiab tsis yog cov ntaub ntawv qub?

Primitive Versus Non-Primitive

  • Cov ntaub ntawv keeb kwm muaj xws li byte, int, ntev, luv, ntab, ob npaug, thiab char.
  • Non-primitive, los yog siv cov ntaub ntawv hom, yog cov tswv cuab ntau dua ntawm cov ntaub ntawv hom tsev neeg.
  • Cov ntaub ntawv siv tau tuaj yeem yog chav kawm, interface, lossis array sib txawv.

Pom zoo: