Write a java method [public static Array List merge (Array List a, Array List b)] that merges two array lists, alternating elements from both array lists. If one array list is shorter than the other,...


Write a java method [public static Array List merge (Array List a, Array List b)] that merges two array lists, alternating elements from both array lists. If one array list is shorter than the other, then alternate as long as you can and then append the remaining elements from the longer array list. For example, if a is 1 4 9 16 and b is 9 7 4 9 11, then merge returns the array lists 1 9 4 7 9 4 16 9 11 PLEASE USE THE BASE CODE BELOW PROVIDED import java.util.ArrayList; public class myARRAYLIST { public static void main(String[] args) { Array List a = new Array List(); Array List b = new Array List(); // Initialize array list a to some values for (int i = 0; i <>

// Initialize array list b to some values bad(9); bad(7); bad(4); bad(9); bad(11);bad(21); System.out.println("ArrayList b is "+b); System.out.println("ArrayList a is " +a); System.out.println("merged is" +merge (am));


} public static ArrayList merge (ArrayListx, ArrayListy)


{ArrayList temp = new ArrayList (size () + size ());


return temp ;}




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here