Prefer primitive types: int, float etc. instead of wrapper types: Integer, Float etc., because they are much more efficient. Instances of wrapper classes are ofcourse objects, which take up more memory than primitives.
Ofcourse sometimes you have to use wrapper types. For example, the Java collection classes can only store objects, not primitives - an ArrayList<int> is impossible, you'll have to use ArrayList<Integer>.
Saurabh S Jain wrote:I used Float in pojo, etc and find its better to use wapper class type variable in place of native data type
What are your reasons to think that using wrapper classes is better than using primitive types?
Saurabh S Jain wrote:Which is best to use
wheather int or Integer, float or Float, Should we define Wapper class type variable?
I used Float in pojo, etc and find its better to use wapper class type variable in place of native data type
It really depends on what you're doing. In some cases you have no choice: For example, you cannot set up a List<int>; it has to be List<Integer> (or, possibly even better, List<AtomicInteger>).
If you're simply using the class as a fixed value then it really doesn't make much difference. On the other hand, if you need to modify it or use it for arithmetic then, as Jesper said, a primitive is much better.
Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here