IndexOutOfBoundsException when adding to ArrayList at index

ArrayList index starts from 0(Zero)

Your array list size is 0, and you are adding String element at 1st index. Without adding element at 0th index you can't add next index positions. Which is wrong.

So, Simply make it as

 s.add("Elephant");

Or you can

s.add(0,"Elephant");

You must add elements to ArrayList serially, starting from 0, 1 and so on.

If you need to add elements to specific position you can do the following -

String[] strings = new String[5];
strings[1] = "Elephant";

List<String> s = Arrays.asList(strings);
System.out.println(s); 

This will produce the sollowing output

[null, Elephant, null, null, null]