Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30692
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!news.swapon.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 | Recommended way to make shallow copy of array |
| Date | 13 Jan 2015 19:50:30 GMT |
| Organization | Private site at Eddersheim, Germany |
| Lines | 16 |
| Distribution | world |
| Message-ID | <m93su6$n1u$1@Gaia.teknon.de> (permalink) |
| X-Trace | individual.net vEKRBOtw1unOomXba4qObwqwQT4J4UGqqn1/z1Jvth3y0K4QRO |
| Cancel-Lock | sha1:xtu+a37EX/4kL/stGVBfKCbMQSA= |
| Xref | csiph.com comp.lang.java.programmer:30692 |
Show key headers only | View raw
Given an array of runtime component type T, I want to create a new array of the same runtime component type referencing the same objects. The two ways I know to achieve this are Arrays.copyOf() and T[].clone(). Target VM is Hotspot Client of Sun JDK 1.7.0_72, will move on to Sun JDK 1.8.0_<then-current> some time not so far in the future. Which method should I prefer? Any other suggestions? Primary use case are defensive copies, where T is some immutable type or a primitive. TIA -- "I'm a doctor, not a mechanic." Dr Leonard McCoy <mccoy@ncc1701.starfleet.fed> "I'm a mechanic, not a doctor." Volker Borchert <v_borchert@despammed.com>
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Recommended way to make shallow copy of array v_borchert@despammed.com (Volker Borchert) - 2015-01-13 19:50 +0000
Re: Recommended way to make shallow copy of array Joerg Meier <joergmmeier@arcor.de> - 2015-01-13 22:40 +0100
Re: Recommended way to make shallow copy of array Joerg Meier <joergmmeier@arcor.de> - 2015-01-13 22:44 +0100
Re: Recommended way to make shallow copy of array Sebastian <news@seyweiler.dyndns.org> - 2015-01-13 23:04 +0100
Re: Recommended way to make shallow copy of array Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-01-13 18:00 -0500
Re: Recommended way to make shallow copy of array v_borchert@despammed.com (Volker Borchert) - 2015-01-19 20:15 +0000
csiph-web