the efficient way would be:
using a loop, pick item from array1 and array2. compare them, and add smallest into a new arrayList., followed by the higher. eventually, convert this arrayList into an int array using arrayList.toArray)int[arraylist.size()]).
why adding into third array? if we pick one from first array and insert into the second array at appropriate place, it will push all subsequent elements and try to increase arrayList2's capacity. these pushing back and increasing are expensive operations. hence creating a new arrayList and adding guarantees a one time iteration.