Integer v/s int
Posted
by
Siddhartha
on Stack Overflow
See other posts from Stack Overflow
or by Siddhartha
Published on 2012-09-01T03:13:07Z
Indexed on
2012/09/01
3:38 UTC
Read the original article
Hit count: 253
Read this on the oracle docs java.lang page:
Frequently it is necessary to represent a value of primitive type as if it were an object. The wrapper classes
Boolean,Character,Integer,Long,Float, andDoubleserve this purpose.
I'm not sure I understand why these are needed. It says they have useful functions such as equals(). But if I can do (a==b), why would I ever want to declare them as Integer, use more memory and use equals()? How does the memory usage differ for the 2?
© Stack Overflow or respective owner