BreakIterator following() method in Java with Examples
The following() method of java.text.BreakIterator class is used to return the index of the first boundary which is present after the specified offset in the line of text. it provides the offset of the first character of the next boundary which follows the passed offset’s boundary.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public abstract int following(int offset)
Parameter: This method takes the offset as a parameter for which required boundary has to found which follows the first one.
Return Value: This method provides the fist boundary after the specified offset.
Exception: This method throws IllegalArgumentException if the offset is less than the first boundary and greater than the last boundary.
Below are the examples to illustrate the following() method:
first boundary for offset 0 : 4 first boundary for offset 4 : 6 first boundary for offset 8 : 11
first boundary for offset 0 : 4 first boundary for offset 4 : 6 offset is less than the first boundary Exception thrown : java.lang.IllegalArgumentException: offset out of bounds