Java ကျူတိုရီရယ်များ

Java ပင်မစာမျက်နှာ Java မိတ်ဆက် Java စတင်လိုက်ပါ။ Java Syntax Java မှတ်ချက်များ Java Variables များ Java Data အမျိုးအစားများ Java အမျိုးအစား Casting Java Operator များ Java စာတန်းများ Java သင်္ချာ Java Booleans Java ဆိုလျှင်... အခြား Java Switch Java while Loop Java For Loop Java Break/Continue Java Arrays

Java နည်းလမ်းများ

Java နည်းလမ်းများ Java Method ကန့်သတ်ချက်များ Java Method လွန်ကဲခြင်း။ Java နယ်ပယ် Java Recursion

Java အတန်းများ

Java OOP Java အတန်းများ/အရာဝတ္ထုများ Java Class Attribute များ Java Class Methods Java တည်ဆောက်သူများ Java ပြုပြင်မွမ်းမံမှုများ Java Encapsulation Java Packages / API Java အမွေအနှစ် Java Polymorphism Java အတွင်းပိုင်းအတန်းများ Java Abstraction Java Interface Java စာရင်းများ Java အသုံးပြုသူ ထည့်သွင်းမှု Java နေ့စွဲ Java ArrayList Java LinkedList Java HashMap Java HashSet Java Iterator Java Wrapper အတန်းများ Java ခြွင်းချက်များ Java RegEx Java Threads Java Lambda

Java ဖိုင်ကို ကိုင်တွယ်ခြင်း။

Java ဖိုင်များ Java ဖိုင်များကို ဖန်တီး/ရေးပါ။ Java ဖိုင်များကိုဖတ်ပါ။ Java ဖိုင်များကိုဖျက်ပါ။

Java လုပ်နည်း

နံပါတ်နှစ်ခုထည့်ပါ။

Java အကိုးအကား

Java သော့ချက်စာလုံးများ Java စာတန်းနည်းလမ်းများ Java သင်္ချာနည်းလမ်းများ

Java ဥပမာများ

Java ဥပမာများ Java Compiler Java လေ့ကျင့်ခန်းများ Java Quiz Java လက်မှတ်


Java ပြုပြင်မွမ်းမံမှုများ


ပြုပြင်မွမ်းမံမှုများ

ယခုအချိန်တွင် publicကျွန်ုပ်တို့၏နမူနာအားလုံးနီးပါးတွင် ပါရှိသည့် သော့ချက်စကားလုံးကို သင်အတော်လေးရင်းနှီးနေပြီဖြစ်သည်-

public class Main

publicသော့ချက်စကားလုံးသည် အတန်း များ၊ အရည်အချင်းများ၊ နည်းလမ်းများနှင့် တည်ဆောက်သူများအတွက် ဝင်ရောက် ခွင့်အဆင့်ကို သတ်မှတ်ရန် အသုံးပြုသည်ဟု ဆိုလိုသည်။

ကျွန်ုပ်တို့သည် ပြုပြင်မွမ်းမံမှုများကို အုပ်စုနှစ်စုခွဲထားသည်-

  • Access Modifiers - ဝင်ရောက်မှုအဆင့်ကို ထိန်းချုပ်သည်။
  • Non-Access Modifiers - ဝင်ရောက်မှုအဆင့်ကို ထိန်းချုပ်မထားသော်လည်း အခြားလုပ်ဆောင်နိုင်စွမ်းများကို ပံ့ပိုးပေးပါသည်။

ပြုပြင်မွမ်းမံမှုများကို အသုံးပြုပါ။

အတန်း များအတွက် သင်သည် တစ်ခုခု publicသို့မဟုတ် ပုံသေ ကို အသုံးပြုနိုင်သည်

Modifier Description Try it
public The class is accessible by any other class
default The class is only accessible by classes in the same package. This is used when you don't specify a modifier. You will learn more about packages in the Packages chapter

attributes များ၊ method များနှင့် constructors များအတွက် ၊ သင်သည် အောက်ပါများထဲမှ တစ်ခုကို အသုံးပြုနိုင်ပါသည်။

Modifier Description Try it
public The code is accessible for all classes
private The code is only accessible within the declared class
default The code is only accessible in the same package. This is used when you don't specify a modifier. You will learn more about packages in the Packages chapter
protected The code is accessible in the same package and subclasses. You will learn more about subclasses and superclasses in the Inheritance chapter

သုံးစွဲခွင့်မရှိသော ပြုပြင်မွမ်းမံမှုများ

အတန်း များအတွက် သင်သည် တစ်ခုခု finalသို့မဟုတ် abstract:

Modifier Description Try it
final The class cannot be inherited by other classes (You will learn more about inheritance in the Inheritance chapter)
abstract The class cannot be used to create objects (To access an abstract class, it must be inherited from another class. You will learn more about inheritance and abstraction in the Inheritance and Abstraction chapters)

ရည်ညွှန်းချက်များနှင့် နည်းလမ်းများ အတွက် သင်သည် အောက်ပါများထဲမှ တစ်ခုကို အသုံးပြုနိုင်ပါသည်။

Modifier Description
final Attributes and methods cannot be overridden/modified
static Attributes and methods belongs to the class, rather than an object
abstract Can only be used in an abstract class, and can only be used on methods. The method does not have a body, for example abstract void run();. The body is provided by the subclass (inherited from). You will learn more about inheritance and abstraction in the Inheritance and Abstraction chapters
transient Attributes and methods are skipped when serializing the object containing them
synchronized Methods can only be accessed by one thread at a time
volatile The value of an attribute is not cached thread-locally, and is always read from the "main memory"


နောက်ဆုံး

ရှိပြီးသား attribute တန်ဖိုးများကို လွှမ်းမိုးနိုင်စွမ်းကို မလိုလားပါက၊ attribute များကို ကြေငြာပါ final-

ဥပမာ

public class Main {
  final int x = 10;
  final double PI = 3.14;

  public static void main(String[] args) {
    Main myObj = new Main();
    myObj.x = 50; // will generate an error: cannot assign a value to a final variable
    myObj.PI = 25; // will generate an error: cannot assign a value to a final variable
    System.out.println(myObj.x);
  }
}


အငြိမ်

method ဆိုသည်မှာ staticclass ၏ object တစ်ခုကို မဖန်တီးဘဲ၊ ၎င်းနှင့် မတူဘဲ ဝင်ရောက်နိုင်သည်ဟု ဆိုလိုသည် public

ဥပမာ

နည်းလမ်းများ staticနှင့် ကွာခြားချက်များကို သရုပ်ပြရန် ဥပမာတစ်ခု ။public

public class Main {
  // Static method
  static void myStaticMethod() {
    System.out.println("Static methods can be called without creating objects");
  }

  // Public method
  public void myPublicMethod() {
    System.out.println("Public methods must be called by creating objects");
  }

  // Main method
  public static void main(String[ ] args) {
    myStaticMethod(); // Call the static method
    // myPublicMethod(); This would output an error

    Main myObj = new Main(); // Create an object of Main
    myObj.myPublicMethod(); // Call the public method
  }
}


စိတ္တဇ

abstractနည်းလမ်းတစ်ခုသည် အတန်းပိုင်ဖြစ်ပြီး ၎င်း တွင် abstractစာကိုယ်မရှိပါ။ ကိုယ်ထည်ကို အမျိုးအစားခွဲများက ပံ့ပိုးပေးသည်-

ဥပမာ

// Code from filename: Main.java
// abstract class
abstract class Main {   public String fname = "John";   public int age = 24;   public abstract void study(); // abstract method } // Subclass (inherit from Main) class Student extends Main {   public int graduationYear = 2018;   public void study() { // the body of the abstract method is provided here     System.out.println("Studying all day long");   } } // End code from filename: Main.java // Code from filename: Second.java class Second {   public static void main(String[] args) {     // create an object of the Student class (which inherits attributes and methods from Main)     Student myObj = new Student();     System.out.println("Name: " + myObj.fname);     System.out.println("Age: " + myObj.age);     System.out.println("Graduation Year: " + myObj.graduationYear);     myObj.study(); // call abstract method
  } }