This is caused by the way how the String representation of the List
is created during the call to List#toString
. This is basically implemented as
firstElement + ", " + secondElement + ", " + ....
So these whitespaces are not in the elements, but only in the String representation of the List itself.
EDIT: You may also verify this by printing something like
System.out.println(">"+list.get(1)+"<");
This will print
>+<
and not
> +<