/* package whatever; // don't place package name! */ import java.util.*;import java.lang.*;import java.io.*; /* Name of the class has to be "Main" only if the class is public. */class Ideone{ static List<String> ll = new ArrayList<String>(); public static void main (String[] args) throws java.lang.Exception { ll.add(0, new String("AAAA")); ll.add(1, new String("BBBB")); ll.add(5, new String("5555")); }}
Standard input is empty
Standard output is empty
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 5, Size: 2 at java.base/java.util.ArrayList.rangeCheckForAdd(ArrayList.java:787) at java.base/java.util.ArrayList.add(ArrayList.java:512) at Ideone.main(Main.java:16)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!