Gives desired output in local compiler but shows error in this case


#1

I used sorting and then appending into a StringBuffer and then print accordingly in the local compiler the desired outut was received but then it says its wrong.
public void merge(ArrayList a, ArrayList b) {
b.addAll(a);
Collections.sort(b);
//System.out.println(b);
StringBuffer sb=new StringBuffer();
for(int i=0;i<b.size();i++){
sb.append(b.get(i));
sb.append(" ");
}
System.out.println(sb);
}

For custom input 2 1 2
2 -1 2 it return s -1 1 2 2 in local compiler where as here it shows -4 3 don’ t know where I went wrong.