Robson Martinz wrote:I don't know exactly when to use Integer or int.
I think Joel's covered most of it, but the main reason not to use
Integers is that they are
immutable.
Unfortunately, all the boxing and unboxing features in
Java sometimes hide that fact from you. For example, if you expanded all of those 'boxing/unboxing' bits in your second loop, you'd get:
for (Integer i = Integer.valueOf(0); i.intValue() < 10;
i = Integer.valueOf(i.intValue() + 1)) { ...
Quite a mouthful, eh? But
that's what's actually happening (or something very similar).
HIH
Winston