Java ArrayList
import java.util.ArrayList;
ArrayList<String> matches = new ArrayList<String>();
matches.add("barcelona");
matches.add("beat");
matches.add("real madrid");
matches.add("4-0");
matches.add("last");
matches.add("year");
System.out.println(matches);
matches.add("."); //adds the ! to the end of the arraylist
matches.add(1, "easily"); //adds the word very to the list at index 4
System.out.println(matches);
ArrayList<String> more_matches = new ArrayList<String>();
more_matches.add("barcelona");
more_matches.add("lost");
more_matches.add("to");
more_matches.add("liverpool");
more_matches.add("4-3"); //this is very true
matches.addAll(more_matches); //adds the second list to the first one
System.out.println(matches);
matches.size();
matches.remove(1); //you can see that the word "are" has been removed
System.out.println(matches);
matches.remove("4-3");
matches.remove("lost");
System.out.println(matches);
matches.get(0);
matches.set(3, new String("CF"));
System.out.println(matches);
matches.indexOf("barcelona");
matches.indexOf("chelsea");
matches.hashCode();
matches.isEmpty();
more_matches.isEmpty();
matches.contains("real madrid");
matches.contains("inter");
import java.util.Collections;
System.out.println("List : "+matches);
//will sort the string according to alphabetical order
Collections.sort(matches);
System.out.println("Sorted List : "+matches);
matches.clear(); //clears all the elements in list
System.out.println(matches); //they're all gone, how sad