Why do hasMoreElements
and hasMoreTokens
return the same value?
since this is a legacy class which implements Enumeration it also uses the method hasMoreTokens for simplicity method naming.
In simple case which uses just the StringTokenizer you can use the hasMoreTokens method. In polymorphic case which you created or already has more implementation of the Enumeraion interface you will use the hasMoreElements which is part of the Enumeraion interface.