If you use the FindBugs plugin (Eclipse -- can run manually, too),
it'll flag all of those "new Integer()" calls, too. It is a
worthwhile plugin/tool.
/dev/mrg
On Dec 29, 2007 5:30 PM, Craig L Russell <Craig.Russel..un.com> wrote:
> I didn't see a reply to this one.
>
> On Dec 20, 2007, at 1:47 AM, Aristedes Maniatis wrote:
>
> >
> > On 20/12/2007, at 8:44 PM, torehalse..pache.org wrote:
> >
> >> java 5: new Integer(int) -> Integer.valueOf(int)
> >
> > Or we could start to use autoboxing and just use "int" where
> > appropriate. Is valueOf recommended over new Integer() for speed or
> > other reasons in Java 5?
>
> Yes, it's recommended. The valueOf method returns an instance that
> might already be lying around whereas new Integer will always create
> an object that will have to be garbage collected later. So valueOf is
> preferable if the code will always be run in a Java 5 or better vm.
>
> Craig
> >
> > Ari
> >
> >
> >
> > -------------------------->
> > Aristedes Maniatis
> > phone +61 2 9660 9700
> > PGP fingerprint 08 57 20 4B 80 69 59 E2 A9 BF 2D 48 C2 20 0C C8
> >
> >
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russel..un.com
> P.S. A good JDO? O, Gasp!
>
>
This archive was generated by hypermail 2.0.0 : Sun Dec 30 2007 - 10:16:31 EST