Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- public class Test17_HM_B {
- public static void main(String[] args) {
- final HashMap<Object,Object> hashMapOne = new HashMap<>();
- hashMapOne.put(1, hashMapOne);
- System.out.println("Size :"+hashMapOne.size());
- System.out.println("Elements : "+hashMapOne.toString());
- System.out.println();
- final HashMap<Object,Object> hashMapTwo = new HashMap<>();
- hashMapTwo.put(2, hashMapTwo);
- System.out.println("Size :"+hashMapTwo.size());
- System.out.println("Elements : "+hashMapTwo.toString());
- System.out.println();
- hashMapTwo.put(1, hashMapOne);
- hashMapOne.put(2, hashMapTwo);
- System.out.println("Size :"+hashMapOne.size());
- System.out.println("Elements : "+hashMapOne.toString()); // It "blows up" here.
- System.out.println();
- System.out.println("Size :"+hashMapTwo.size());
- System.out.println("Elements : "+hashMapTwo.toString());
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement