StringBuilder sb = new StringBuilder("Java Programming") įollowing is the output of the above program − Using the offsetB圜odePoints() method, we are trying to get the index value at the specified index -1 and codePointOffset 5. If the following program, we are instantiating the StringBuilder class with the value “Java Programming”. If the given index value is negative and greater than the sequence length, the offsetB圜odePoint() method throws an IndexOutOfBoundIndex. The given index and code point offset values are: 2 and 5 On executing the above program, it will produce the following result − ("The index is: " + sb.offsetB圜odePoints(index, codePointOffset)) ("The given index and code point offset values are: " + index + " and " + codePointOffset) initialize the index and codePointOffset values StringBuilder sb = new StringBuilder("TutorialsPoint") create an object of the StringBuilder class Using the offsetB圜odePoints(), we are trying to get the index value at the specified startIndex 2, and the codePointOffset 5. In the following program, we are creating an object of the StringBuilder class with the value of “TutorialsPoint”. If the given index value is positive and less than the sequence length, the offsetB圜odePoint() method returns the index value. This method returns the index within this sequence. Public int offsetB圜odePoints(int index, int codePointOffset)ĬodePointOffset − This is the offset in code points. Syntaxįollowing is the syntax of the Java StringBuilder offsetB圜odePoints() method − It throws different exceptions if the index value is negative or greater than the sequence length, and so on. The offsetB圜odePoints() method accepts two parameters as an integer that holds the values of index and codePointOffset. A stream contains an integer code point values, which is similar to the ASCII value in Java. This method returns a stream of code point values of the sequence character. The given index and code point offset values are: 10 and 2Įxception e: Java StringBuilder offsetB圜odePoints() method is, used to retrieve the index value within this sequence that is offset from the given index by codePointOffset code points. The above program produces the following output − StringBuffer sb = new StringBuffer("Hello") Using the offsetB圜odePoints() method, we are, trying to get the index value at the specified startIndex 10, and codePointOffset 2. In the following example, we are creating a StringBuffer with the value “Hello”. If the given index value is larger than the sequence length, this method throws the IndexOutOfBoundException. The given index and code point offset values are: -1 and 5Īt java.base/圜odePoints(AbstractStringBuilder.java:461)Īt java.base/圜odePoints(StringBuffer.java:279)Īt OffsetCodePoint.main(OffsetCodePoint.java:15)Įxception e: StringBuffer sb = new StringBuffer("Java Programming") įollowing is the output of the above program − If the following program, we are instantiating the StringBuffer class with the value “Java Programming”. ![]() ![]() StringBuffer sb = new StringBuffer("TutorialsPoint") create an object of the StringBuffer class ![]() In the following program, we are creating an object of the StringBuffer class with the value of “TutorialsPoint”. Syntaxįollowing is the syntax of the Java StringBuffer offsetB圜odePoints() method − The Java StringBuffer offsetB圜odePoints() method is, used to retrieve the index value within this sequence that is offset from the given index by codePointOffset code points.
0 Comments
Leave a Reply. |