import java.util.ArrayList;

ArrayList<String> physics = new ArrayList<String>();

add(int index, element)

physics.add("potential energy");
physics.add("kinetic energy");
physics.add("conservation of energy");
true

addAll(int index, Collection collection)

import java.util.ArrayList;

ArrayList<String> calculators = new ArrayList<String>();

physics.addAll(calculators);
System.out.println("Calculators:" + physics + "\n");
Calculators:[potential energy, kinetic energy, conservation of energy]

size() This method is used to return the size of the list.

System.out.println("The number of calculators on the website is currently " + physics.size());
The number of calculators on the website is currently 3

clear() This method is used to remove all the elements in the list. However, the reference of the list created is still stored.

calculators.clear();
System.out.println("Calculators: " + calculators);
Calculators: []

remove(int index) This method removes an element from the specified index. It shifts subsequent elements(if any) to left and decreases their indexes by 1.

physics.remove(0);
System.out.println("Calculators: " + physics);
Calculators: [kinetic energy, conservation of energy]

remove(element) This method is used to remove the first occurrence of the given element in the list.

physics.add("Work");

physics.remove("Potential Energy");
System.out.println("Calculators" + physics);
Calculators[kinetic energy, conservation of energy, Work]

get(int index) This method returns elements at the specified index.

System.out.println("The first calculator is " + physics.get(0));
The first calculator is kinetic energy

set(int index, element) This method replaces elements at a given index with the new element. This function returns the element which was just replaced by a new element.

physics.set(0, "Kinetic Energy");
System.out.println("Calculators: " + physics);
Calculators: [Kinetic Energy, conservation of energy, Work]

indexOf(element) This method returns the first occurrence of the given element or -1 if the element is not present in the list.

System.out.println("The gravity calculator is " + physics.indexOf("the first calculator"));
The gravity calculator is -1

lastIndexOf(element) This method returns the last occurrence of the given element or -1 if the element is not present in the list.

System.out.println("The potential energy calculator is " + physics.indexOf("Physics Tutoring 1 hr sessions"));
The potential energy calculator is -1

equals(element) This method is used to compare the equality of the given element with the elements of the list.

if (physics.equals(calculators) == true) {
    System.out.println("The inventory matches the listings!");
}
else {
    System.out.println("The inventory does not match the listings!");
}
The inventory does not match the listings!

hashCode() This method is used to return the hashcode value of the given list.

System.out.println("The hashcode for this list is " + physics.hashCode());
The hashcode for this list is 832184209

isEmpty() This method is used to check if the list is empty or not. It returns true if the list is empty, else false.

System.out.println("Calculators is empty " + physics.isEmpty());
Calculators is empty false

contains(element) This method is used to check if the list contains the given element or not. It returns true if the list contains the element.

System.out.println("Calculators contains potential energy is " + physics.contains("potential energy"));
Calculators contains potential energy is false

containsAll(Collection collection) This method is used to check if the list contains all the collection of elements.

if (physics.containsAll(calculators) == true) {
    System.out.println("The calculators are all working");
}
else {
    System.out.println("The calculators are broken");
}
The calculators are all working

sort(Comparator comp) This method is used to sort the elements of the list on the basis of the given comparator.

Collections.sort(physics);
System.out.println("Calculators arranged " + physics);
Calculators arranged [Kinetic Energy, Work, conservation of energy]