Advertisement

01.29.2008 at 07:41AM PST, ID: 23119578
[x]
Attachment Details

iterating over elements of a HashMap

Asked by DJ_AM_Juicebox in Java Programming Language

Tags: hashmap, iterating, over

Hi,

I made a HashMap<String, Integer>. I want to iterator over all elements.

for (Iterator it = m_Table.values().iterator(); it.hasNext();) {
    Map.Entry entry = (Map.Entry)it.next();
    String strKey = (String)entry.getKey()
    Integer nData = (Integer)entry.getValue() ;
}

This causes a runtime exception though... what's the right way to do it?

ThanksStart Free Trial
[+][-]01.29.2008 at 07:44AM PST, ID: 20768777

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: hashmap, iterating, over
Sign Up Now!
Solution Provided By: ksivananth
Participating Experts: 3
Solution Grade: A
 
 
[+][-]01.29.2008 at 07:44AM PST, ID: 20768779

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.29.2008 at 07:50AM PST, ID: 20768835

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 07:58AM PST, ID: 20768922

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 07:59AM PST, ID: 20768930

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 07:59AM PST, ID: 20768941

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 08:00AM PST, ID: 20768945

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 08:44AM PST, ID: 20769503

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 08:53AM PST, ID: 20769637

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.29.2008 at 08:55AM PST, ID: 20769663

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628