What is the difference between Integer and int?
Answer Posted / devendra
An int is a primitive. It is not an Object.int variables
are mutable. Unless you mark them final, you can change
their value at any time.
An Integer, is a Object that contains a single int
field.Integers are immutable. If you want to affect the
value of a Integer variable, the only way is to create a
new Integer object and discard the old one.
Converting
// to int i from Integer ii
int i = ii.intValue();
// to Integer ii from int i
Integer ii = new Integer( i );
| Is This Answer Correct ? | 27 Yes | 3 No |
Post New Answer View All Answers
Which methods cannot be overridden in java?
What are meta-annotations?
Outline the major features of java.
How many types of voids are there?
How many bytes is a unicode character?
Can we override singleton class?
Can we overload the main() method?
How do you calculate roots in java?
What is thread pool? How can we create thread pool in java?
What is the char data type?
What is a website container?
In the below example, how many string objects are created?
What is the size of a string in java?
What are different types of encoding?
How do you check if a number is a perfect square?