while comparing like if( a.get(i) != b.get(j))
for input [1, 1, 1], output is 
for input [5000, 5000, 5000], output is [5000, 5000, 5000]
if stored in int variable first and then compared, i.e.,
int first = a.get(i);
int second = b.get(j);
if(first != second)
output is fine.
why that happens??