Which one is best in programming - int
or Integer
? Especially whenever both are doing the same task?
I am writing an appli
Use int
wherever possible. Use Integer
only if:
Integer
can be null
, an int
always has an int value.List
(though you can use int
externally and have autoboxing hide the fact that the collection internally stores Integer
instances).Integer
or Object
, or doesn't work with primitive types.