The following is compact and avoids the loop in your example code (and gives you nice commas):
(以下是紧凑的,并且避免了示例代码中的循环(并为您提供了漂亮的逗号):)
System.out.println(Arrays.toString(list.toArray()));
However, as others have pointed out, if you don't have sensible toString() methods implemented for the objects inside the list, you will get the object pointers (hash codes, in fact) you're observing.
(但是,正如其他人指出的那样,如果您没有为列表内的对象实现明智的toString()方法,则将获得要观察的对象指针(实际上是哈希码)。)
This is true whether they're in a list or not. (无论他们是否在列表中,都是如此。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…