queryParms.add(new Long(empRec));
I am using JDK 1.5 and using wrapped longs to a list. My Boss was yelling at me seeing this.
Is it a good approach?
Does it impact in terms of performance.
What should be alternative?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is unnecessary to do this. Java does it automatically with autoboxing.
In short – collections don’t accept primitives. So whenever you call
collection.add(longVar)it is automatically translated tocollection.add(Long.valueOf(longVar))Another thing – don’t use the constructor
new Long(..)even in cases where autoboxing doesn’t work. UseLong.valueOf(..)– it first looks in a cache ofLonginstances. From the documentation ofLong.valueOf(..):