简体   繁体   中英

Outer Loop and Inner Loop in Java HashMap

I have written below code:

for(Long value : hmapA.values()) {
    System.out.println("Value = " + value);
    for (Long value1 : hmapQ.values()) {
        System.out.println("ValueQ = " + value1);
    }
}

Inner loop never runs, what could be the reason?

Keep in mind that you are referencing different hashmaps (hmapA and hmapQ). If your outer loop runs and the inner doesn't, then the condition of the inner loop is false, which could very well be that hmapQ is empty.

But we would need more of your code to decisively understand the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM