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 is the escape character in java?
what is session in java?
What is the purpose of the return statement?
Explain java coding standards for interfaces?
What is a ?
Is string serializable in java?
How many types of keywords are there?
What is a vector in java?
What are the differences between heap and stack memory?
Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?
Which object oriented concept is achieved by using overloading and overriding?
What is a platform?
Write a code to show a static variable?
What is the difference between JVM and JRE?
What are three types of loops in java?