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


Please Help Members By Posting Answers For Below Questions

What are the Static and Dynamic Variables? Differentiate them.

592


What is synchronization and why is it important in java programming?

468


Can each java object keep track of all the threads that want to exclusively access it?

527


What is java Applet?

640


What is super in java?

567






Is ++ operator thread-safe in java?

624


What is api data?

524


What is the concept of multithreading?

514


Can I import same package/class twice?

484


How many ways can we create singleton class?

496


Explain access specifiers?

651


What are streams?

628


Can a final variable be initialized in constructor?

481


What is object english?

575


What are the 4 types of research methods?

504