Java data types ကို အဓိကအားဖြင့် Primitive Types နဲ့ Reference Types ဆိုပြီးခွဲနိုင်ပါတယ်။ Primitive type တွေက value ကိုတိုက်ရိုက်သိမ်းပြီး reference type တွေက object/location ကိုရည်ညွှန်းပါတယ်။ Beginner အတွက် အရင်ဆုံး သိသင့်တာက data အမျိုးအစားမှန်မှ operation မှန်မှာဖြစ်ပါတယ်။ ဥပမာ phone number ကို math တွက်ချင်တာမဟုတ်ရင် String နဲ့သိမ်းတာက ပိုသင့်တော်နိုင်ပါတယ်။
public class Main {
public static void main(String[] args) {
int quantity = 3;
double price = 19.99;
char grade = 'A';
boolean isAvailable = true;
String productName = "Keyboard";
System.out.println(productName + " x " + quantity);
System.out.println("Total: " + (quantity * price));
System.out.println("Grade: " + grade);
System.out.println("Available: " + isAvailable);
}
}ဒီ example မှာ product order တစ်ခုလို data တွေကို type အမျိုးမျိုးနဲ့သိမ်းထားပါတယ်။ quantity * price က numeric types နှစ်ခုကို multiplication လုပ်ပြီး total price ထုတ်ပါတယ်။
Keyboard x 3 Total: 59.97 Grade: A Available: trueလက်တွေ့အသုံးချမှု
E-commerce order, school grading, booking status, payment amount စတဲ့ real app data model တွေမှာ data type ရွေးချယ်မှုက အရေးကြီးပါတယ်။