can i place a map inside a list interface in java please help me with a example
How to place a map inside a list interface in Java?
Collapse
X
-
Tags: None
-
Yes. Possible.
Code:List l = new LinkedList(); HashMap mp = new HashMap(); mp.put("1", "one"); mp.put("2", "two"); l.add(mp); for (Object object : l) { HashMap hp = (HashMap)object; if(hp.get("1").equals("one")){ System.out.println("True"); } else{ System.out.println("False"); } }
Dheeraj Joshi -
-
Comment