Enumeration Interface
Enumeration Interface -
Enumeration interface used for retrieve the elements one by one from collection.
It makes a read only copy of objects and puts in enumeration. You can retrieve elements only.
Enumeration interface has two methods only.
boolean hasMoreElements() -
This method is used to ensure that enumeration has elements or not. It return true if enumeration has elements otherwise return false.
E nextElement() -
This method is used for retrieve the elements from enumeration. It throws NoSuchElementException if there is no element in enumeration.
There are some classes which implements enumeration Interface.
1.StringTokenizer
Enumeration interface used for retrieve the elements one by one from collection.
It makes a read only copy of objects and puts in enumeration. You can retrieve elements only.
Enumeration interface has two methods only.
boolean hasMoreElements() -
This method is used to ensure that enumeration has elements or not. It return true if enumeration has elements otherwise return false.
E nextElement() -
This method is used for retrieve the elements from enumeration. It throws NoSuchElementException if there is no element in enumeration.
There are some classes which implements enumeration Interface.
1.StringTokenizer
Comments
Post a Comment