Link to home
Start Free TrialLog in
Avatar of _Esam
_Esam

asked on

How to use Enumeration in Java 5 to iterate throug the keys?

Hi,

Java 1.4 had this code:

ResourceBundle resources =
                ResourceBundle.getBundle( "KeyConstants" );
            Enumeration enum = resources.getKeys();
            while (  enum.hasMoreElements()) {
                final String key = (String)enum.nextElement();
                final String value = resources.getString( key );
                if ( value != null ) {
                    keysMap.put( key, value );
                }
            }

It works fine with Java 1.4


But in 5.0, it does not work.

RAD 7 says:

Multiple markers at this line
   - Enumeration cannot be resolved
   - Syntax error on token "enum", delete this token


import java.util.Enumeration; Enumeration was imported though.

How do I fix this in Java 5 ?



Thanks.
_Esam.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _Esam
_Esam

ASKER

Yes, u r right,
I just found out that was the problem .. it's a keywork in java 5

Thax
_Esam
:-)