I am very much confused between hasmoreelements and hasmoretokens method of stringtokenizer.
I want to know what's the difference
Can anybody clear my confusion?
Thanks
I am very much confused between hasmoreelements and hasmoretokens method of stringtokenizer.
I want to know what's the difference
Can anybody clear my confusion?
Thanks
I want to know what's the difference
From the Java API doc:
hasMoreElements()
Returns the same value as the hasMoreTokens method. It exists so that this class can implement the Enumeration interface.
There is no difference from a functional perspective.
hasMoreElements()
needs to be there because StringTokenizer
implements the Enumeration
interface.
As per API
public boolean hasMoreTokens()
Returns true if more tokens exist.
public boolean hasMoreElements()
Returns true if the Enumeration has more elements.
So Bottem line is they are same and It supports Enumeration
There seems be no difference as the javadoc says:
boolean hasMoreElements() Returns the same value as the hasMoreTokens method. hasMoreElements.It exists so that this class can implement the Enumeration interface.
boolean hasMoreTokens() Tests if there are more tokens available from this tokenizer's string.
hasMoreElements returns the same value as the hasMoreTokens method. It exists so that this class can implement the Enumeration interface.