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 is the escape character in java?

513


what is session in java?

751


What is the purpose of the return statement?

519


Explain java coding standards for interfaces?

630


What is a ?

755






Is string serializable in java?

542


How many types of keywords are there?

564


What is a vector in java?

576


What are the differences between heap and stack memory?

550


Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

554


Which object oriented concept is achieved by using overloading and overriding?

557


What is a platform?

542


Write a code to show a static variable?

618


What is the difference between JVM and JRE?

622


What are three types of loops in java?

588