What is the difference between Integer and int?
Answers were Sorted based on User's Feedback
Answer / janet
Integer is a class defined in the java.lang package,where
as int is a primitive data tyep defined in the java
language itself.Java doesn't automatically convert from one
to the other.
Integer can be used as an argument for a method that
requires an object,where as int can be used for
calculations.
| Is This Answer Correct ? | 59 Yes | 9 No |
Answer / k.santosh kumar
int is a primitive data type , where as Integer is a class
which encapsulates the primitive int data type and
represents in terms of object.
| Is This Answer Correct ? | 35 Yes | 6 No |
Answer / ravikiran(aptech mumbai)
Integer is a wrapper class object where as int is a
primitive datatype
| Is This Answer Correct ? | 31 Yes | 4 No |
Answer / 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 |
Answer / sumit
int is a premitive data type and integer is a class
| Is This Answer Correct ? | 14 Yes | 7 No |
Answer / duryodhan
int is a primitive data type & integer is a wapper class object which define in java.lang package.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / maninder sharma
Integer is a class defined in the java.lang package,where
as int is a primitive data type.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / tapan kumar
int is a primitive type by the int we can set and read the
value but Integer is a wrapper class type u can use for
finding the length and for size .
| Is This Answer Correct ? | 4 Yes | 4 No |
What does a void function return?
What is the Concept of Encapsulation in OOPS
Why unicode is important?
How many bytes is a string in java?
as we know a static method could access static data and static method only. then how could main method call the object of aclass which is not static and other non static data
what modifiers are used with top-level class?
What is difference between static class and normal class?
What is difference between identifier and variable?
What is immutable class? how to make a Class explicitly "Immutable"?Wap to make a class explicitly immutable.
What is the use of flag?
import java.io.*; class Demo { public static void main(String args[]) { File f=new File("1234.msg"); String arr[]=f.list(); System.out.println(arr.length); } }
Is namespace same as package in java?