The next() method of java.text.CharacterIterator interface in Java is used to get the next character that is to be read by this CharacterIterator. This method decrements this iterator to one index forward and returns that next character.
Syntax:
public char next()
Parameter: This method do not accept any parameter.
Return Value: This method returns the next character that is to be read by this CharacterIterator.
Exception: This method do not throw any Exception.
Program:
// Java program to demonstrate // the above method import java.text.*; import java.util.*; public class CharacterIteratorDemo { public static void main(String[] args) { CharacterIterator characterIterator = new StringCharacterIterator( "GeeksForGeeks"); System.out.println("Current character: " + characterIterator .current()); System.out.println("Next character: " + characterIterator .next()); } } |
Current character: G Next character: e
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/CharacterIterator.html#next–
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- CharacterIterator current() method in Java with Examples
- CharacterIterator first() method in Java with Examples
- CharacterIterator previous() method in Java with Examples
- CharacterIterator getIndex() method in Java with Examples
- CharacterIterator setIndex() method in Java with Examples
- CharacterIterator getEndIndex() method in Java with Examples
- CharacterIterator clone() method in Java with Examples
- CharacterIterator last() method in Java with Examples
- CharacterIterator getBeginIndex() method in Java with Examples
- BreakIterator setText(CharacterIterator) method in Java with Examples
- CollationElementIterator setText(CharacterIterator) method in Java with Example
- RuleBasedCollator getCollationElementIterator(CharacterIterator) method in Java
- Random next() method in Java with Examples
- StringCharacterIterator next() method in Java with Examples
- BreakIterator next(int) method in Java with Examples
- BreakIterator next() method in Java with Examples
- CollationElementIterator next() method in Java with Examples
- TemporalAdjusters next() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

