BreakIterator last() method in Java with Examples Last Updated : 27 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The last() method of java.text.BreakIterator class is used to get the index of the last boundary. It always return the offset of the last character of last boundary. Syntax: public abstract int last() Parameter: This method does not accept any parameter. Return Value: This method provides the index of the last boundary. Below are the examples to illustrate the last() method: Example 1: Java // Java program to demonstrate last() method import java.text.*; import java.util.*; import java.io.*; public class GFG { public static void main(String[] argv) { // creating and initializing BreakIterator BreakIterator wb = BreakIterator.getWordInstance(); // setting text for BreakIterator wb.setText("Code Geeks"); // getting the index of last text boundary int last = wb.last(); // display the result System.out.println("last boundary : " + last); } } Output: last boundary : 11 Example 2: Java // Java program to demonstrate last() method import java.text.*; import java.util.*; import java.io.*; public class GFG { public static void main(String[] argv) { // creating and initializing BreakIterator BreakIterator wb = BreakIterator.getWordInstance(); // setting text for BreakIterator wb.setText("GeeksForGeeks"); // getting the index of last text boundary int last = wb.last(); // display the result System.out.println("last boundary : " + last); } } Output: last boundary : 13 Reference: https://docs.oracle.com/javase/9/docs/api/java/text/BreakIterator.html#last-- Comment More infoAdvertise with us Next Article CharacterIterator last() method in Java with Examples R rohitprasad3 Follow Improve Article Tags : Java Java-Functions Java-text package Java-BreakIterator Practice Tags : Java Similar Reads CharacterIterator last() method in Java with Examples The last() method of java.text.CharacterIterator interface in Java is used to get the character at the ending of this CharacterIterator. This method sets the position of the iterator to the last character, using getEndIndex(), and then returns that character. Syntax: public char last() Parameter: Th 1 min read BreakIterator next() method in Java with Examples The next() method of java.text.BreakIterator class is used to get the index of the next boundary ahead of the current boundary(boundary retrieved by calling current() method). it provides the offset of the first character of boundary which follows the current boundary pointed by BreakIterator. Synta 2 min read BreakIterator first() method in Java with Examples The first() method of java.text.BreakIterator class is used to get the index of the first boundary.it always return the start index of first boundary.it provides the offset of first character of first boundary. Syntax: public abstract int first() Parameter: This method does not accept any parameter. 2 min read BreakIterator current() method in Java with Examples The current() method of java.text.BreakIterator class is used to get the index of recent text boundary in the line of words. It provides the offset of the text which is currently pointed by the BreakIterator. Syntax: public abstract int current() Parameter: This method does not accept any parameter. 3 min read BreakIterator getText() method in Java with Examples The getText() method of java.text.BreakIterator class is used to get the text previously set by the setText() method in breakiterator.Syntax: public abstract CharacterIterator getText() Parameter: This method does not accept any parameter.Return Value: This method provides the text scanned previousl 2 min read BreakIterator previous() method in Java with Examples The previous() method of java.text.BreakIterator class is used to get the index of the previous boundary behind the current boundary(boundary retrieved by calling current() method). It provides the offset of the first character of boundary which precedes the current boundary pointed by BreakIterator 3 min read Like