What exactly does comparing Integers with == do?
问题 EDIT: OK, OK, I misread. I'm not comparing an int to an Integer. Duly noted. My SCJP book says: When == is used to compare a primitive to a wrapper, the wrapper will be unwrapped and the comparison will be primitive to primitive. So you'd think this code would print true : Integer i1 = 1; //if this were int it'd be correct and behave as the book says. Integer i2 = new Integer(1); System.out.println(i1 == i2); but it prints false . Also, according to my book, this should print true : Integer