Reputation:
I read that Integer and Long class have its private collections for caching purposes, that mean that if I create two variables Integer a, b = 1, both would be the same objects as for "==" check.
What about int a,b = 1 - these are only primitives, can we call them objects? Are they also cached somehow in Integer class or JVM?
Upvotes: 0
Views: 70
Reputation: 73548
No, they're not cached and you can't call them objects.
It doesn't make sense to cache primitives, since there's no object creation involved.
Upvotes: 2