Implementing Java Interfaces - Exercise
In this exercise, you must implement an interface defined in the java.util package, called Enumeration.
Refer to the API documentation for a description of this interface.
Create a class
You will see that the Enumeration interface defines two methods: hasMoreElements() and nextElement().
Your mission is to create a class called StringEnumeration that implements this interface and provides behavior for
these two methods.
In particular, once you create your new StringEnumeration class and add it to the following file, you will have a complete, working
application in which the StringEnumeration class is used to generate a series of Character objects corresponding to the characters of a String object.
Here's the code for the class SuperString that contains a main() method that makes use of the StringEnumeration class.
classSuperString {
public static void main(String[] args) {
StringEnumeration se = new StringEnumeration("Hello, World!");
while (se.hasMoreElements())
System.out.println(se.nextElement());
}
}