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 does this mean java?
Explain an algorithm to find depth of a binary tree.
What are the two ways of implementing multi-threading in java?
Can string be considered as a keyword?
What are static methods?
How can constructor chaining be done by using the super keyword?
What about instanceof operator in java?
Will the compiler creates a default constructor if I have a parameterized constructor in the class?
How to make a read-only class in java?
What is externalizable interface?
What are drawbacks of singleton class?
What is the difference between static (class) method and instance method?
Is main is a keyword?
What does sizeof return?
What is java oops?