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
What are the Static and Dynamic Variables? Differentiate them.
What is synchronization and why is it important in java programming?
Can each java object keep track of all the threads that want to exclusively access it?
What is java Applet?
What is super in java?
Is ++ operator thread-safe in java?
What is api data?
What is the concept of multithreading?
Can I import same package/class twice?
How many ways can we create singleton class?
Explain access specifiers?
What are streams?
Can a final variable be initialized in constructor?
What is object english?
What are the 4 types of research methods?