Labels

Java Data Types

 

Java Data Types

အရှေ့တွင် ရှင်းပြထားသကဲ့သို့ Java တွင် variable တစ်ခုသည် သီးခြား data type တစ်ခု ဖြစ်ရမည်။
ဥပမာ။
int myNum = 5;               // Integer (whole number)
float myFloatNum = 5.99f;    // Floating point number
char myLetter = 'D';         // Character
boolean myBool = true;       // Boolean
String myText = "Hello";     // String

Data types များကို အဓိကအားဖြင့် Primitive data types နှင့် Non-primitive data types ဟူ၍ နှစ်ပိုင်းခွဲခြားနိုင်သည်။

Primitive data types တွင် byte, short, int, long, float, double, boolean နှင့် char တို့ ပါဝင်သည်။

Non-primitive data types တွင် String, Arrays နှင့် Classes တို့ ပါဝင်သည်။

Primitive Data Types

Primitive data types များသည် variable values များ၏ size နှင့် type များအတွက်အထူးသတ်မှတ်ချက်များရှိပြီး ၄င်းတွင် ထပ်ထိုး method များဟူ၍မရှိပေ။


Data TypeSizeDescription
byte1 byteStores whole numbers from -128 to 127
အနှုတ်တန်ဖိုး -၁၂၈ မှ အပေါင်းတန်ဖိုး ၁၂၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။
short2 bytesStores whole numbers from -32,768 to 32,767
အနှုတ်တန်ဖိုး -၃၂၇၆၈ မှ အပေါင်းတန်ဖိုး ၃၂၇၆၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။
int4 bytesStores whole numbers from -2,147,483,648 to 2,147,483,647
အနှုတ်တန်ဖိုး -၂ ၁၄၇ ၄၈၃ ၆၄၈ မှ အပေါင်းတန်ဖိုး ၂ ၁၄၇ ၄၈၃ ၆၄၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။
long8 bytesStores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
အနှုတ်တန်ဖိုး -၉ ၂၂၃ ၃၇၂ ၀၃၆ ၈၅၄ ၇၇၅ ၈၀၈ မှ အပေါင်းတန်ဖိုး ၉ ၂၂၃ ၃၇၂ ၀၃၆ ၈၅၄ ၇၇၅ ၈၀၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။
float4 bytesStores fractional numbers. Sufficient for storing 6 to 7 decimal digits
ဒသမတန်ဖိုး ၆ လုံး ကနေ ၇ လုံး ထိ သိမ်းဆည်းနိုင်သည်။
double8 bytesStores fractional numbers. Sufficient for storing 15 decimal digits
ဒသမတန်ဖိုး ၁၅ လုံးအထိလုံလောက်စွာ သိမ်းဆည်းနိုင်သည်။
boolean1 bitStores true or false values
true သို့မဟုတ် false တန်ဖိုးများ သာသိမ်းဆည်းနိုင်သည်။
char2 bytes   Stores a single character/letter or ASCII values
တစ်လုံးတည်းသော character သို့ letter များ နှင့် ASCII ကသတ်မှတ်ထားသော charactor တန်ဖိုးများ သိမ်းဆည်းနိုင်သည်။

Java Numbers

Number များဟာ primitive type ဖြစ်ပြီး အုပ်စု အားဖြင့် Integer types နှင့် Floating point types ဟူ၍ ၂ ပိုင်းခွဲခြားနိုင်သည်။

Integer types သည် ၁၂၃ (သို့) -၄၅၆ ဆိုသည့် ဒသမတန်ဖိုးများ မပါဝင်သည့် အပေါင်း အနှုတ် ကိန်းပြည့်တန်ဖိုးများ ဖြစ်ပြီး byte, short, int နှင့် long စသည့် type များအားလက်ခံသည်။ 
မည်သည့် အမျိုးအစား  (variable type) အား အသုံးပြုသင့်သည်ဆိုသည်မှာ  ကိန်းဂဏန်းတန်ဖိုးများအပေါ် မူတည်သည်။

Floating point types သည် ဒသမ ပိုင်းခြားထားသည့် ကိန်းဂဏန်းတန်ဖိုးများကို ကိုယ်စားပြုပြီး တစ်ခုထက်ပိုသော့ ဒသမနောက် တန်ဖိုးများပါဝင်နိုင်သည်။ float နှင့် double ဟူ၍ နှစ်မျိုးခွဲခြားနိုင်သည်။

Java တွင် ကိန်းဂဏန်းနှင့်ပါတ်သက်၍ များစွာသော numeric types များစွာ ရှိသော်လည်း ကိန်းဂဏန်းများအတွက် အဓိကအသုံးအများဆုံး type များမှာ int (ကိန်းပြည့်တန်ဖိုးများအတွက်) နှင့် double (ဒသမကိန်းများအတွက်) များဖြစ်သည်။ 

No comments:

Post a Comment

FinTech

 "FinTech" is a term that combines "financial" and "technology" and refers to the use of technology to provide...