Java String သည် equals() Method ဖြစ်သည်။
ဥပမာ
ညီမျှခြင်းရှိမရှိ သိရှိရန် စာကြောင်းများကို နှိုင်းယှဉ်ကြည့်ပါ-
String myStr1 = "Hello";
String myStr2 = "Hello";
String myStr3 = "Another String";
System.out.println(myStr1.equals(myStr2)); // Returns true because they are equal
System.out.println(myStr1.equals(myStr3)); // false
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် equals()
strings နှစ်ခုကို နှိုင်းယှဉ်ပြီး strings များ ညီလျှင် true နှင့် မဟုတ်ပါက false ပြန်ပေးသည်။
အကြံပြုချက်- မျဉ်းကြောင်း နှစ်ခုကို အဘိဓာန်အရ နှိုင်းယှဉ်ရန်နှိုင်းယှဉ် To() နည်းလမ်းကို အသုံးပြု ပါ။
အထားအသို
public boolean equals(Object anotherObject)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
anotherObject | An Object , representing the other string
to be compared |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့သည်- | boolean တန်ဖိုး
-
|
---|---|
အစားထိုးခြင်းများ- | equals အတန်းထဲမှာObject |
❮ စာတန်းနည်းလမ်းများ