import java.util.*; class UseArrayLists10 // Shows adding an integer after all occurrences of an integer // constructively in an ArrayList, then doing the same with Strings. // Uses a generic method. { 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("The ArrayList created is "+b); System.out.println("\nEnter some words (all on one line, separated by spaces):"); line = input.nextLine(); line = input.nextLine(); String[] words = line.split(" "); ArrayList c = new ArrayList(); for(int i=0; i d=addAfter(c,str1,str2); System.out.println("The ArrayList created is "+d); } public static ArrayList addAfter(ArrayList a,T m,T n) // Adds n after every occurrence of m in a, constructively. { ArrayList b = new ArrayList(); for(int i=0; i