Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: v_borchert@despammed.com (Volker Borchert) Newsgroups: comp.lang.java.programmer Subject: Re: Recommended way to make shallow copy of array Date: 19 Jan 2015 20:15:22 GMT Organization: Private site at Eddersheim, Germany Lines: 29 Distribution: world Message-ID: References: X-Trace: individual.net fmfnNgZSyOwi8AhUwpXy+gxgB9bv18bFP2GERNyDqc94LfbAOO Cancel-Lock: sha1:UOsWSR/taPR+ojrFCZTbn92HCl8= Xref: csiph.com comp.lang.java.programmer:30750 Sebastian wrote: > - use System.arraycopy (useful in particular when copying parts of an > array) That's what Array.copyOf() and Arrays.copyOfRange() do. > The for-loop, copyOf and System.arraycopy styles clearly have > independent storage, a clone of a one-dimensional array has independent > storage, but the clone of a multi-dimensional array does not. > > System.arraycopy seems to have slightly better performance. > Arrays.copyOf is easiest to use with dynamic typing. The question is, what happens when the JIT kicks in and starts inlining and/or intrinsifying... > Differences between the various methods are small, however, and might be > regarded a micro-optimization. OK that should do, at least for now and until proven wrong. Thanks -- "I'm a doctor, not a mechanic." Dr Leonard McCoy "I'm a mechanic, not a doctor." Volker Borchert