import java.util.*; class UseArrayLists6 // Shows adding an integer after all occurrences of an integer // constructively in an ArrayList { public static void main(String[] args) throws Exception { Scanner input = new Scanner(System.in); System.out.println("Enter some numbers (all on one line, separated by spaces):"); String line = input.nextLine(); String[] numbers = line.split(" "); ArrayList a = new ArrayList(); for(int i=0; i b=addAfter(a,p,q); System.out.println("\nThe ArrayList created is "+b); System.out.println("The original ArrayList is still "+a); } public static ArrayList addAfter(ArrayList a,int m,int n) // Adds n after every occurrence of m in a, constructively { ArrayList b = new ArrayList(); for(int i=0; i