Check the code below and run it:
public class ListExample { public static void main(String[] args) { List<String> myList = new ArrayList<String>(); myList.add("one"); myList.add("two"); myList.add("three"); myList.add("four"); myList.add("five"); System.out.println("Inserted in 'order': "); printList(myList); System.out.println("\n"); System.out.println("Inserted out of 'order': ");
It produces the following output:
Inserted in 'order': one two three four five Inserted out of 'order': four five one two three
For more information, see the documentation: List (Java Platform SE7)
axcdnt Jul 04 2018-12-12T00: 00Z
source share