An int and Integer in Java and C# are two different terms used to represent different things. It is one of the the primitive data types that can be assigned to a variable that can store exactly. One value of its declared type at a time.
For example:
int number = 7;
Where int
is the datatype assigned to the variable number which holds the value seven. So an int
is just a primitive not an object.
While an Integer
is a wrapper class for a primitive data type which has static methods. That can be used as an argument to a method which requires an object, where as int can be used as an argument to a method which requires an integer value, that can be used for arithmetic expression.
For example:
Integer number = new Integer(5);