What is the Difference between Enumeration and Iterator interface?
Enumeration and Iterator are the interface available
in java.util package. The functionality of Enumeration interface is duplicated
by the Iterator interface. New implementations should consider using Iterator
in preference to Enumeration.
Iterators differ from enumerations in following
ways:
Enumeration contains 2 methods namely
·
hasMoreElements()
·
nextElement()
whereas Iterator contains three methods namely
·
hasNext(),
·
next(),
·
remove().
Iterator adds an optional remove operation, and has
shorter method names. Using remove() we can delete the objects but Enumeration
interface does not support this feature.
Enumeration interface is used by legacy classes.
Vector.elements() & Hashtable.elements() method returns Enumeration.
Iterator is returned by all Java Collections Framework classes.
java.util.Collection.iterator() method returns an instance of Iterator.
What are transient variables? What role do they play
in Serialization process?
The transient keyword in Java is used to indicate
that a field should not be serialized. Once the process of de-serialization is
carried out, the transient variables do not undergo a change and retain their
default value. Marking unwanted fields as transient can help you boost the
serialization performance.
Visit:www.sssedu.inhttp://sssedu.in/java-training-in-chennai.html
No comments:
Post a Comment