I came across a class using Integer variables to capture size to be used in a for loop. Is this good practice or should we use the int primitive data type?
I
When there is a need of using objects, you have to use the Wrapper classes, like Integer, Double, Float, etc...
eg:
int n = Integer.parseInt("10");
Here we are converting the string to an integer (Primitive type) , but method parseInt(String str) works only on Wrapper classes (ie Object), so we used it... you will find many more use of it in java.