new String is object and new Integer not object
Because you immediately assigned the Integer
s to a primitive type, not an object type. If you had written
Integer d=new Integer(5);
Integer d2=new Integer(5);
then d != d2
as expected, not least because the results of any two distinct invocations of new
will be !=
to each other.
8
solved different new String and new Integer in java?