HashMap<> entrySet

S

Steve Green

I am using the current stable release of Eclipse 3.1. I know it is not
finalized yet but I am new to generics and am not sure if I am bouncing up
against a bug or a mistake in my code.

The following code is reported back as an error by Eclipse.

HashMap<String,MDDatabase> hm = new HashMap<String,MDDatabase>();
Iterator<MDDatabase> it = s.getDatabases().entrySet().iterator();

Shouldn't entrySet() return an iterator to the type MDDatabase?
It is saying that it should be Map.Entry<String,MDDatabase>.

Steve
 
C

Chris Smith

Steve Green said:
I am using the current stable release of Eclipse 3.1. I know it is not
finalized yet but I am new to generics and am not sure if I am bouncing up
against a bug or a mistake in my code.

The following code is reported back as an error by Eclipse.

HashMap<String,MDDatabase> hm = new HashMap<String,MDDatabase>();
Iterator<MDDatabase> it = s.getDatabases().entrySet().iterator();

Shouldn't entrySet() return an iterator to the type MDDatabase?
It is saying that it should be Map.Entry<String,MDDatabase>.

No, Eclipse is right. If you want to iterate over MDDatabase only, then
use s.getDatabases().values() instead of s.getDatabases().entrySet().

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top