What are the different ways of creating Wrapper Class Instances
Integer fifttyfive = new Integer("55");//String
Integer hundred =Integer.valueOf("100");//100 is stored in variable
Integer seven =Integer.valueOf("111", 2);//binary 111 is converted to 7
The difference is that using the Constructor you will always create a new object, while using valueOf()static method, it may return you a cached value with-in a range.We should prefer static valueOf method, because it may save you some memory
For example : The cached values for long are between [-128 to 127].