_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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
ASKER
I just found out that was the problem .. it's a keywork in java 5
Thax
_Esam