Are the Integer a = new Integer(10); and Integer a = Integer.valueOf(10); commands same?
Will it be same?
You must be signed in to leave a comment
5 November 2022, 18:20
Thanks..My problem is resolved
5 November 2022, 13:16
no, valueOf and autoboxing trigger caching (static Integer objects already initialized inside the Integer class for values form -128 to 127) while the constructor always creates a new instance. In addition to that the constructor is deprecated since 9.