Java add an element at a specified position in an ArrayList

Java add an element at a specified position in an ArrayList
refer to‮ttual:‬uri.com
/**
 * @author lautturi.com
 * Java example: add an element to arrayList in java
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {
		
		// create ArrayList
	    ArrayList<String> strs = new ArrayList<>();

	    // add() method without the index parameter
	    strs.add("Java");
	    strs.add("Python");
	    strs.add("Lautturi");
	    
	    // add element at index 0
	    strs.add(0, "Lautturi.com");

	    // add element at index 3
	    strs.add(3, "world");
	    System.out.println("ArrayList: " + strs);

	}

}

Output:

ArrayList: [Lautturi.com, Java, Python, world, Lautturi]
Created Time:2017-08-30 09:23:01  Author:lautturi