Differences between new Integer(123), Integer.valueOf(123) and just 123
问题 Recenlty I saw code (Java) like this: myMethod(new Integer(123)); I am currently refactoring some code, and there is a tip in Sonar tool, that it's more memory friendly to use sth like this: myMethod(Integer.valueOf(123)); However in this case, I think that there is no difference if I would use: myMethod(123); I could understand that, if I would pass a variable to the method, but hard coded int? Or if there would be Long/Double etc and I want Long representation of number. But integer? 回答1: