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 |
❮ วิธีการสตริง