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
How do you check if a string is lexicographically in java?
What is skeleton and stub?
What is the difference between notify and notifyall method?
What is a marker interface?
Can we use synchronized block for primitives?
What are the main concepts of oops in java?
What is the difference between static (class) method and instance method?
Which is illegal identifier in java?
Which list does not allow duplicates in java?
What is the difference between super class & sub class?
What is the difference between yielding and sleeping in java programming?
Differentiate between postfix and prefix operators in java.
Does java trim remove newline?
Can we overload final method in java?
Why main function is static?