JPad
Snippets
Download
Help
Contact
Adding to a Map
Code
Map<String,Integer> a = new HashMap<String,Integer>(); a.put("one",1); a.put("two",2); a.put("one hundred",100); Dump(a);
Result
Console
{one=1, two=2, one hundred=100}
Bytecode
Compiled from "RunnContainer.java" public class io.jpad.scratch.RunnContainer { public io.jpad.scratch.RunnContainer(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String...) throws java.lang.Exception; Code: 0: new #2 // class java/util/HashMap 3: dup 4: invokespecial #3 // Method java/util/HashMap."<init>":()V 7: astore_1 8: aload_1 9: ldc #4 // String one 11: iconst_1 12: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 15: invokeinterface #6, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 20: pop 21: aload_1 22: ldc #7 // String two 24: iconst_2 25: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 28: invokeinterface #6, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 33: pop 34: aload_1 35: ldc #8 // String one hundred 37: bipush 100 39: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 42: invokeinterface #6, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 47: pop 48: aload_1 49: invokestatic #9 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 52: pop 53: return }
Jpad Version:1.04
viewCount:3057
Creator:
admin
Latest Editor:
admin
Tags
map
hashmap
Download
Copy As Markdown:
**code [Adding to a Map.java](/example/1o/adding-to-a-map)** Map
a = new HashMap
(); a.put("one",1); a.put("two",2); a.put("one hundred",100); Dump(a); **Result:** {one=1, two=2, one hundred=100}