Your code appears Fine.
A simple logic modification that you can do is instead of using count++ for every repeated values,just
put the integers from Array A to your ArrayList<> and when putting the next integer from Array A just parse through the ArrayList<> to check whether we have the number already present. Then same can be done for Array B.
solved Union of two Arrays without default functions in Java [closed]