Java စာကြောင်းကုဒ်PointCount() နည်းလမ်း
ဥပမာ
စာကြောင်းတစ်ခုတွင် တွေ့ရသော ယူနီကုဒ်တန်ဖိုး အရေအတွက်ကို ပြန်ပေးပါ။
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် codePointCount()
စာကြောင်းတစ်ခုတွင်တွေ့ရသော ယူနီကုဒ်တန်ဖိုးအရေအတွက်ကို ပြန်ပေးသည်။
ရှာဖွေမှုကို စတင်ရန်နှင့် အဆုံးသတ်ရန် နေရာသတ်မှတ်ရန် startIndex နှင့် endIndex ဘောင် များကို အသုံးပြု ပါ။
ပထမအက္ခရာ၏အညွှန်းကိန်းသည် 0 ဖြစ်ပြီး၊ ဒုတိယအက္ခရာမှာ 1၊ စသည်တို့ဖြစ်သည်။
အထားအသို
public int codePointCount(int startIndex, int endIndex)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
startIndex | An int value, representing the index to
the first character in the string |
endIndex | An int value, representing the index
after the last character in the string |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့သည်- | int စာကြောင်းတစ်ခုတွင်တွေ့ရသော ယူနီကုဒ်တန်ဖိုးများ အရေအတွက်ကို ကိုယ်စားပြုသော တန်ဖိုး တစ်ခု |
---|---|
ပစ်သည် | IndexOutOfBoundsException - startIndex သည် အနုတ်ဖြစ်လျှင် သို့မဟုတ် endindex သည် စာကြောင်း၏အရှည်ထက် ပိုကြီးသည်၊ သို့မဟုတ် startIndex သည် endIndex ထက် ပိုကြီးသည် |
Java ဗားရှင်း- | ၁.၅ |
❮ စာတန်းနည်းလမ်းများ