JPad
Snippets
Download
Help
Contact
Adding to an ArrayList
Version 2
Code
List<String> l = new ArrayList<>(); l.add("one"); l.add("two"); Dump(l);
Result
Console
[one, two]
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/ArrayList 3: dup 4: invokespecial #3 // Method java/util/ArrayList."<init>":()V 7: astore_1 8: aload_1 9: ldc #4 // String one 11: invokeinterface #5, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z 16: pop 17: aload_1 18: ldc #6 // String two 20: invokeinterface #5, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z 25: pop 26: aload_1 27: invokestatic #7 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 30: pop 31: return }
Jpad Version:1.05
viewCount:4384
Creator:
admin
Latest Editor:
admin
Tags
ArrayList
list
Download
Copy As Markdown:
**code [Adding to an ArrayList.java](/example/1r/adding-to-an-arraylist)** List
l = new ArrayList<>(); l.add("one"); l.add("two"); Dump(l); **Result:** [one, two]