Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class BookNumbers {
    public static void main(String args[]) {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        map.put(1, 2);
        map.put(3, 4);
        map.put(5, 6);
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            System.out.println(entry.getKey() + "/" + entry.getValue());
        }
    }
}


1/2
3/4
5/6
2/1
4/3
6/5
5/6
3/4
1/2
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java HashMap Implementation

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App