Lists and ArrayLists

import java.util.ArrayList;
import java.util.Comparator;

// Create an ArrayList object
ArrayList<String> artists = new ArrayList<String>();


// add(int index, element)
artists.add("Taylor Swift");
artists.add("50 Cent");
artists.add("Miley Cyrus");

System.out.println("- add(int index, element)");
System.out.println(artists + "\n");


// addAll(int index, Collection collection)
ArrayList<String> songs = new ArrayList<String>();
songs.add("Shake It Off");
songs.add("In Da Club");
songs.add("Party In The USA");

artists.addAll(songs);

System.out.println("- addAll(int index, Collection collection)");
System.out.println(artists + "\n");


// size()
System.out.println("- size()");
System.out.println("There are " + artists.size() + " terms in the ArrayList artists");
System.out.println("There are " + songs.size() + " terms in the ArrayList songs" + "\n");


// clear()
songs.clear();

System.out.println("- clear()");
System.out.println(songs+ "\n");


// remove(int index)
artists.remove(5);
System.out.println("- remove(int index)");
System.out.println(artists + "\n");


// remove(element)
artists.remove("Miley Cyrus");

System.out.println("- remove(element)");
System.out.println(artists + "\n");


// get(int index)
System.out.println("- get(int index)");
System.out.println(artists.get(1) + "\n");


// set(int index, element)
artists.set(3, "Candy Shop");

System.out.println("- set(int index, element)");
System.out.println(artists + "\n");


// indexOf(element)
System.out.println("- indexOf(element)");
System.out.println(artists.indexOf("50 Cent") + "\n");


// lastIndexOf(element)
System.out.println("- lastIndexOf(element)");
System.out.println(artists.indexOf("Candy Shop") + "\n");


// equals(element)
System.out.println("- equals(element)");
System.out.println(artists.equals("Snoop Dogg"));



// hashCode()
System.out.println("\n" + "- hashCode()");
System.out.println(artists.hashCode() + "\n");


// isEmpty()
System.out.println("- isEmpyty()");
System.out.println(artists.isEmpty() + "\n");


// contains(element)
System.out.println("- contains(element)");
System.out.println(artists.contains("50") + "\n");


// containsAll(Collection collection)
System.out.println("- containsAll(Collection collection)");
System.out.println(artists.contains(songs) + "\n");


// sort(Comparator comp)
System.out.println("- sort(Comparator comp)");
artists.sort(Comparator.naturalOrder());
System.out.println(artists);
- add(int index, element)
[Taylor Swift, 50 Cent, Miley Cyrus]

- addAll(int index, Collection collection)
[Taylor Swift, 50 Cent, Miley Cyrus, Shake It Off, In Da Club, Party In The USA]

- size()
There are 6 terms in the ArrayList artists
There are 3 terms in the ArrayList songs

- clear()
[]

- remove(int index)
[Taylor Swift, 50 Cent, Miley Cyrus, Shake It Off, In Da Club]

- remove(element)
[Taylor Swift, 50 Cent, Shake It Off, In Da Club]

- get(int index)
50 Cent

- set(int index, element)
[Taylor Swift, 50 Cent, Shake It Off, Candy Shop]

- indexOf(element)
1

- lastIndexOf(element)
3

- equals(element)
false

- hashCode()
-1198696971

- isEmpyty()
false

- contains(element)
false

- containsAll(Collection collection)
false

- sort(Comparator comp)
[50 Cent, Candy Shop, Shake It Off, Taylor Swift]