Java StringBuilder codePointBefore()方法与示例
StringBuilder類codePointBefore()方法 (StringBuilder Class codePointBefore() method)
codePointBefore() method is available in java.lang package.
codePointBefore()方法在java.lang包中可用。
codePointBefore() method is used to represent the Unicode code point before the given index and array indexing starts from 0 to length() - 1.
codePointBefore()方法用于表示給定索引和數組索引從0開始到length()-1之前的Unicode代碼點。
codePointBefore() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
codePointBefore()方法是一個非靜態方法,只能使用類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。
codePointBefore() method may throw an exception at the time of assigning index.
在分配索引時, codePointBefore()方法可能會引發異常。
IndexOutOfBoundsException - This exception may throw when the given argument value is not less than the length or denotes negative value.
IndexOutOfBoundsException-當給定的參數值不小于長度或表示負值時,可能引發此異常。
Syntax:
句法:
public int codePointBefore(int indices)Parameter(s):
參數:
int indices – represents the index of following the Unicode code point that should be retrieved.
int index –表示應檢索的Unicode代碼點之后的索引。
Return value:
返回值:
The return type of this method is int, t returns the Unicode code point before the given indices.
此方法的返回類型為int ,t返回給定索引之前的Unicode代碼點。
Example:
例:
// Java program to demonstrate the example // of int codePointBefore(int indices) method of StringBuilder public class CodePointBefore {public static void main(String[] args) {// Creating an StringBuilder objectStringBuilder st_b = new StringBuilder("Java");System.out.println("st_b = " + st_b);// By using codePointBefore(2) method is to return the codepoint// at before the given index 2 i.e. it returns codepoint at // following the given index i.e index 1int cp = st_b.codePointBefore(2);// Display codepoint value at before the given index 2System.out.println("st_b.codePointBefore(2)=" + cp);} }Output
輸出量
st_b = Java st_b.codePointBefore(2)=97翻譯自: https://www.includehelp.com/java/stringbuilder-codepointbefore-method-with-example.aspx
總結
以上是生活随笔為你收集整理的Java StringBuilder codePointBefore()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python函数示例_带Python示例
- 下一篇: JDK 9 对字符串 String 的优