طريقة Java String codePointCount ()
مثال
قم بإرجاع عدد قيم Unicode الموجودة في سلسلة:
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
التعريف والاستخدام
تقوم codePointCount()
الطريقة بإرجاع عدد قيم Unicode الموجودة في سلسلة.
استخدم معلمات 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 قيمة تمثل عدد قيم Unicode الموجودة في سلسلة |
---|---|
رميات: | IndexOutOfBoundsException - إذا كانت قيمة startIndex سالبة ، أو كان endindex أكبر من طول السلسلة ، أو إذا كان startIndex أكبر من endIndex |
نسخة جافا: | 1.5 |
❮ طرق السلسلة