Java ဆိုတာ ဘာလဲ
Java ဆိုသည်မှာ computer software များ ရေးသားရာတွင် အသုံးပြုသည့် high level programming language တစ်မျိုးဖြစ်ပါသည်။ High level programming language အမြောက်အများ ရှိသည့် အနက် java သည် ယနေ့ ခေါတ်တွင်အသုံးအများဆုံး programming language တစ်ခု အဖြစ် ရပ်တည်လျက်ရှိပါသည်။ အောက်ပါ အချက်များကြောင့် java သည်ယနေ့တိုင် တွင်ကျယ်စွာ အသုံးပြုနေကြခြင်းဖြစ်သည်။
1. Platform Independence (WORA)
Java သည် "Write Once, Run Anywhere" (WORA) principle ပေါ်တွင် အခြေခံထားသည်။ အဓိပ္ပါယ်မှာ Java သည် တစ်ကြိမ်ရေးသားထားရုံဖြင့် နေရာတိုင်းမှာ run နိုင်သည်ဟု ဆိုလိုခြင်းဖြစ်သည်။ သက်ဆိုင်ရာ Operating System များပေါ်တွင်မမှီခိုပဲ Java ၏ ကိုယ်ပိုင် JVM (Java Virtual Machine) ဟုခေါ်သော ကိုယ်ပိုင် Java Engine ပေါ်တွင် အလုပ်လုပ်နိုင်ခြင်းကြောင့်ဖြစ်သည်။ အသုံးပြုလိုသည့် Operation System များပေါ်တွင် သက်ဆိုင်ရာ JDK (Java Development Kit) အား install ပြုလုပ်ပြီး Java Source file မှ bytecode သို့ compile လုပ်စေပြီး machine နားလည်နိုင်ရန် JVM သည် ကြားမှ interpreted လုပ်ပေးနိုင်သောကြောင့် ဖြစ်သည်။
2. Object-Oriented Programming (OOP)
Java သည် encapsulation, inheritance, and polymorphism စသည့် Object-Oriented Programming principles များကို အခြေခံထားပြီး ထိုအချက်သည် modular and reusable code ဟုသော အပိုင်းအလိုက်ခွဲခြားနိုင်ခြင်းနှင့် ပြန်လည်အသုံးပြုနိုင်သော code များ ရေးသားနိုင်ရန် အထောက်အကူပြုသည်။
3. Automatic Memory Management (Garbage Collection)
Java သည် garbage collector အား အသုံးပြု၍ memory အား အလိုအလျောက် စီမံခန့်ခွဲနိုင်ပြီး မလိုအပ်သော memory leaks ဖြစ်ခြင်းများကို ရှောင်ရှားစေနိင်သည်။ developer များမှ အထူးတလည် စီမံခန်ခွဲရန် မလိုအပ်ပေ။
4. Rich Standard Library (Java API)
Java သည် ကျယ်ကျယ်ပျံ့ပျံ့ အသုံးပြုနိုင်သော standard library များ ထောက်ပံ့ပေးထားပြီး I/O, networking, data structures, utilities နှင့် အခြားသော စသည့် functionalities များလုပ်ဆောင်ရာတွင် အဆင်ပြေစွာလုပ်ဆောင်နိုင်သည်။
5. Security
Java တွင် robust security model, classloaders, sandbox environment ကဲ့သို့သော built-in security features များပါဝင်ပြီး java application များ ရေးသာရာတွင့် secure ဖြစ်စေရန်ကာကွယ်ပေးထားသည်။
6. Multithreading
Java သည် Multithreading အား support ပေးထားပြီး concurrent နှင့် parallel program များရေးသားနိုင်သည်။ ထိုအရာသည် scalable နှင့် responsive application များ တည်ဆောက်ရာတွင် မရှိမဖြစ်လိုအပ်သည့် အရာဖြစ်သည်။
7. Networking
Java သည် networking အတွက် ကောင်းစွာ ထောက်ပံ့ပေးထားပြီး network application များ distributed application များ develop လုပ်ရာတွင်အလွန်အရေးပါသည်။ Java Networking API သည် client-serve application များ တည်ဆောက် ရာတွင် အလွန်ရိုးရှင်းအောင်ထောက်ပံ့ပေးထားသည်။
8. Distributed Computing (RMI and CORBA)
RMI (Remote Method Invocation) ဆိုသည်မှာ network တစ်ခုအတွင်း မတူညီသော Java Virtual Machines (JVMs) များရှိ objects များကြား ဆက်သွယ်နိုင်သော Java-specific technology တစ်ခုဖြစ်ပြီး ၄င်းသည် remote objects များအား local object အဖြစ်အသုံးပြုနိုင်ရန် ခွင့်ပြုပေးသည်။
CORBA (Common Object Request Broker Architecture) ဆိုသည်မှာ language-agnostic middleware ဟုခေါ်သော language တစ်ခုပေါ်တွင် မမှီခိုပဲ မတူညီသော languages များကြား objects များ အပြန်အလှန် ဆက်သွယ်နိုင်စေရန်နှင့် network တစ်ခုပေါ်ရှိ distributed objects များကြား အချင်းချင်း ဆက်သွယ်နိုင်ရန် စံသတ်မှတ်ချက် တစ်ခု အဖြစ်ထောက်ပံ့ပေးထားသည်။
အချုပ်အားဖြင့် ဆိုသော် RMI နှင့် CORBA နှစ်ခုလုံးသည် Java ၏ distributed computing mechanisms အားထောက်ပံ့ပေးထားပြီး RMI သည် Java အတွက်သာဖြစ်ပြီး CORBA သည် language independence ဖြစ်သည်။ language များကြား အပြန်အလှန်လုပ်ဆောင်နိုင်မှု နှင့် ရှိနှင့်ပြီးသား infrastructure များစသည့် factors များပေါ် မူတည်၍ ၄င်းတို့အား ရွေးချယ်အသုံးပြုနိုင်သည်။
9. Dynamic and Extensible
Java သည် runtime တွင့် classes များအား dynamic loading လုပ်ဆောင်ခြင်း နှင့် dynamic linking လုပ်ဆောင်ခြင်းအား ထောက်ပံ့ပေးပြီး dynamic dvelopment နှင့် application များ extensible ဖြစ်နိုင်စေရန်လည်း ထောက်ပံ့ပေးထားသည်။
10. Popular Frameworks and Libraries
Java တွင် Spring, Hibernate, Apache Struts ကဲ့သို့ များစွာသော frameworks များ၊ libraries များနှင့် အတူကောင်းမွန်သော ecosystem တစ်ခု ရှိပြီး အမျိုးမျိုးသော application များ develop လုပ်နိုင်သည်။
Java သည် web development အပါအဝင် mobile app develpment(Android), enterprise software, scientific computing နှင့် အခြား အမျိုးမျိုးသော application domains များတွင် အသုံးပြုနေကြပြီး ၎င်း၏ကျော်ကြားမှု၊ ဘက်စုံအသုံးပြုနိုင်မှုနှင့် ခိုင်မာသောအသိုင်းအဝိုင်းပံ့ပိုးမှုတို့သည် ဆော့ဖ်ဝဲလ်ဖွံ့ဖြိုးတိုးတက်မှုအခင်းအကျင်းတွင် ၎င်းင်း၏အသက်ရှည်မှုနှင့် ဆက်လက်ဆက်စပ်မှုရှိစေရန် အထောက်အကူဖြစ်စေပါသည်။
Java သမိုင်းကြောင်း
Java အခြေခံသင်ခန်းစာများ
Java ဆိုတာဘာလဲ?
ဘာကြောင့် Java သုံးကြသလဲ?
Java Install
Java Comments
Single-line Comments
// This is a comment
System.out.println("Hello World");System.out.println("Hello World"); // This is a comment
Multi-line Comments
/* The code below will print the words Hello World
to the screen, and it is amazing */
System.out.println("Hello World");Java Variables
- String - "Hello" ကဲ့သို့သော စာ (Text) များ သိမ်းဆည်းနိုင်ပြီး String value များအား " (double quotes) အဖွင့်အပိတ်များကြား ရေးသားရသည်။
- int - ကိန်းဂဏန်းတန်ဖိုး integers (numbers) များသိမ်းဆည်းနိုင်ပြီး ဒသမ (decimals) တန်ဖိုးများ မပါဝင်ပေ။ ဥပမာ 123, -123 ကဲ့သို့ အပေါင်း သို့ အနှုတ် ကိန်းပြည့်တန်ဖိုးများဖြစ်ကြသည်။
- float - ဒသမ (deimals) ပါသော floating point numbers များ သိမ်းဆည်းနိုင်သည်။ ဥပမာ - 19.99 သို့ -19.99
- char - 'a' သို့ 'B' ကဲ့သို့သော တစ်လုံးတည်းသော အက္ခရာ (single character) များ သိမ်းဆည်းနိုင်ပြီး ၄င်းအား ' (single quote) များ အတွင်းရေးသားရသည်။
- boolean - true or false, yes or no ကဲ့သို့ ဟုတ်တယ် မဟုတ်ဘူး အခြေအနေပြတန်ဖိုးများသာ သိမ်းဆည်းနိုင်သည်။
Declaring (Creating) Variables
type variableName = value;String name = "John";
System.out.println(name);int myNum = 15;
System.out.println(myNum);int myNum;
myNum = 15;
System.out.println(myNum);int myNum = 15;
myNum = 20; // myNum is now 20
System.out.println(myNum);Final Variables
final int myNum = 15;
myNum = 20; // will generate an error: cannot assign a value to a final variableOther Types
int myNum = 5;
float myFloatNum = 5.99f;
char myLetter = 'D';
boolean myBool = true;
String myText = "Hello";Java Print Variables (Display Variables)
String name = "John";
System.out.println("Hello " + name);String firstName = "John ";
String lastName = "Doe";
String fullName = firstName + lastName;
System.out.println(fullName);int x = 5;
int y = 6;
System.out.println(x + y); // Print the value of x + yJava Declare Multiple Variables
int x = 5;
int y = 6;
int z = 50;
System.out.println(x + y + z);int x = 5, y = 6, z = 50;
System.out.println(x + y + z);One Value to Multiple Variables
int x, y, z;
x = y = z = 50;
System.out.println(x + y + z);Java Identifiers
// Good
int minutesPerHour = 60;
// OK, but not so easy to understand what m actually is
int m = 60;- Variable Name များပေးရာတွင် letters, digits, underscores နှင့် dollar signs($) များပါဝင်နိုင်သည်။
- အစ စာလုံးသည် letter ဖြစ်ရမည်။
- အစ စာလုံးသည် အက္ခရာစာလုံး (lowercase letter) အသေးဖြစ်သင့်ပြီး wihtespce မပါရပေ။
- အစ စာလုံးသည် $ (dollar sign) နှင့် _ (underscore) တို့ဖြင့်လည်း စနိုင်သည်။
- Variable Name တွင် case sensitive အက္ခရာ အကြီးအသေးအလိုက် ကွဲ့ပြားခြင်းရှိသည်။ (ဥပမာ- "myVar" နှင့် "myvar" သည် မတူညီကွဲပြားသည့် variable များဖြစ်ကြသည်။)
- Reserved words များ ဖြစ်သည့် Java တွင် သတ်မှတ်ထားပြီးသော Java ၏ keywords များ အား အသုံးပြု၍ မရပေ။ (ဥပမာ - "int" or "boolean")
int myNum = 5; // Integer (whole number)
float myFloatNum = 5.99f; // Floating point number
char myLetter = 'D'; // Character
boolean myBool = true; // Boolean
String myText = "Hello"; // StringPrimitive Data Types
| Data Type | Size | Description |
|---|---|---|
byte | 1 byte | Stores whole numbers from -128 to 127 အနှုတ်တန်ဖိုး -၁၂၈ မှ အပေါင်းတန်ဖိုး ၁၂၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။ |
short | 2 bytes | Stores whole numbers from -32,768 to 32,767 အနှုတ်တန်ဖိုး -၃၂၇၆၈ မှ အပေါင်းတန်ဖိုး ၃၂၇၆၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။ |
int | 4 bytes | Stores whole numbers from -2,147,483,648 to 2,147,483,647 အနှုတ်တန်ဖိုး -၂ ၁၄၇ ၄၈၃ ၆၄၈ မှ အပေါင်းတန်ဖိုး ၂ ၁၄၇ ၄၈၃ ၆၄၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။ |
long | 8 bytes | Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 အနှုတ်တန်ဖိုး -၉ ၂၂၃ ၃၇၂ ၀၃၆ ၈၅၄ ၇၇၅ ၈၀၈ မှ အပေါင်းတန်ဖိုး ၉ ၂၂၃ ၃၇၂ ၀၃၆ ၈၅၄ ၇၇၅ ၈၀၇ အထိလက်ခံသိမ်းဆည်းနိုင်သည်။ |
float | 4 bytes | Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits ဒသမတန်ဖိုး ၆ လုံး ကနေ ၇ လုံး ထိ သိမ်းဆည်းနိုင်သည်။ |
double | 8 bytes | Stores fractional numbers. Sufficient for storing 15 decimal digits ဒသမတန်ဖိုး ၁၅ လုံးအထိလုံလောက်စွာ သိမ်းဆည်းနိုင်သည်။ |
boolean | 1 bit | Stores true or false values true သို့မဟုတ် false တန်ဖိုးများ သာသိမ်းဆည်းနိုင်သည်။ |
char | 2 bytes | Stores a single character/letter or ASCII values တစ်လုံးတည်းသော character သို့ letter များ နှင့် ASCII ကသတ်မှတ်ထားသော charactor တန်ဖိုးများ သိမ်းဆည်းနိုင်သည်။ |
Java Numbers
Integer Types
Byte
byte data type သည် အနုတ်တန်ဖိုး -၁၂၈ မှ အပေါင်းတန်ဖိုး ၁၂၇ အထိ သိမ်းဆည်းနိုင်ပြီး int ထက် ပို၍ memory ချွေတာနိုင်သည်။ အကယ်၍ သင်၏ တန်ဖိုးမှ အနုတ် -၁၂၈ မှ အပေါင်းတန်ဖိုး ၁၂၇ အတွင်းဖြစ်လျှင် int အစား ၄င်း data type ကို အသုံးပြုသင့်သည်။
ဥပမာ။
byte myNum = 100;
System.out.println(myNum);Short
short data type သည် အနုတ်တန်ဖိုး -၃၂၇၆၈ မှ အပေါင်းတန်ဖိုး ၃၂၇၆၇ ထိ သိမ်းဆည်းနိုင်သည်။
ဥပမာ။
short myNum = 5000;
System.out.println(myNum);Int
The int data type can store whole numbers from -2147483648 to 2147483647. In general, and in our tutorial, the int data type is the preferred data type when we create variables with a numeric value.
int data type သည် အနုတ်တန်ဖိုး -၂၁၄၇၄၈၃၆၄၈ မှ အပေါင်းတန်ဖိုး ၂၁၄၇၄၈၃၆၄၇ ထိ သိမ်းဆည်းနိုင်သည်။ များသောအားဖြင့် သင်္ချာတန်ဖိုး(numeric value) များ အတွက် variables များ ကြေညာရာတွင် int data type သည် အသုံးအများဆုံးဖြစ်သည်။
ဥပမာ။
int myNum = 100000;
System.out.println(myNum);Long
The long data type can store whole numbers from -9223372036854775808 to 9223372036854775807. This is used when int is not large enough to store the value. Note that you should end the value with an "L":
long data type သည် အနုတ်တန်ဖိုး -၉၂၂၃၃၇၂၀၃၆၈၅၄၇၇၅၈၀၈ မှ အပေါင်းတန်ဖိုး ၉၂၂၃၃၇၂၀၃၆၈၅၄၇၇၅၈၀၈ ထိ သိမ်းဆည်းနိုင်သည်။
ဥပမာ။
long myNum = 15000000000L;
System.out.println(myNum);Floating Point Types
You should use a floating point type whenever you need a number with a decimal, such as 9.99 or 3.14515.
အကယ်၍များ ၉.၉၉ (သို့) ၃.၁၄၅၁၅ ကဲ့သို့ ဒသမတန်ဖိုး (decimal) များ သုံးဖို့ လိုအပ်လာတဲ့အခါ floating point type ကို အသုံးပြုနိုင်သည်။
The float and double data types can store fractional numbers. Note that you should end the value with an "f" for floats and "d" for doubles:
float နဲ့ double data type များသည် fractional number များ သိမ်းဆည်းနိုင်ပြီး တန်ဖိုး (value) ၏ အဆုံးတွင် floats များအတွက် "f" နှင့် doubles များအတွက် "d" ဟု ထည့်သွင်း အသုံးပြုနိုင်သည်။
No comments:
Post a Comment