import java.util.*; class ArrayListOps { public static void destChange(ArrayList a,T m,T n) // Change all occurrences of m to n in a, destructively { for(int i=0; i ArrayList constChange(ArrayList a,T m,T n) // Change all occurrences of m to n in a, constructively { ArrayList b = new ArrayList(); for(int i=0; i void destAddAfter(ArrayList a,T m,T n) // Adds n after every occurrence of m in a, destructively { for(int i=0; i ArrayList constAddAfter(ArrayList a,T m,T n) // Adds n after every occurrence of n in a constructively. { ArrayList b = new ArrayList(); for(int i=0; i void destReverse(ArrayList a) // Reverse a, destructively { int mid = a.size()/2; for(int i=0; i ArrayList constReverse(ArrayList a) // Reverse a, constructively { ArrayList b = new ArrayList(); for(int i=a.size()-1; i>=0; i--) b.add(a.get(i)); return b; } }