Saturday, April 27, 2019

what will be the output of the following java code?

Problem statement:
what will be the output of the following code?

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
  1. public class Solutions {
  2.     public static void main(String[] args) {
  3.         HashMap<Integer, String> m = new HashMap<>();
  4.         m.put(1001,"A");
  5.         m.put(1002,"B");
  6.         //Collections.unmodifiableMap(m);
  7.         m.put(1001,"C");
  8.         System.out.println(m);
  9.     }
  10. }
Output: {1001=C, 1002=B}

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...