a java problem with obvious solution
Apr. 10th, 2005 11:01 pmSitting late on Sunday, writing stupid programs... what do you think this program would print?
public static void main(String[] args) {
List l0 = new Vector();
List[] lists = new List[] {
l0,
new ArrayList(),
new LinkedList(),
Arrays.asList(new Object[0]),
Collections.EMPTY_LIST,
Collections.nCopies(0, l0),
Collections.synchronizedList(l0),
Collections.synchronizedList(new Vector())};
for (List l1 : lists) {
for (List l2 : lists) {
if (l1 != l2 && !l1.equals(l2)) {
System.out.println("oops, " + l1 +
" is not the same as " + l2 +
"!");
}
}
}
}