Annoying 1.5 warnings

H

Hendrik Maryns

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) schreef:
Point well taken, but how do I clone() a Vector<Integer> without a
warning?

new Vector<Integer>(oldVector);

Are you sure you do not want an ArrayList?

H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFFADn6e+7xMGD3itQRAqU3AJ92LSeha8Bxa5BAJCy55tmBNGWYwQCcDoae
YI0p/IjLSjHnUAOlX1uYAHw=
=9RoR
-----END PGP SIGNATURE-----
 
R

ricky.clarkson

Clone is a broken API in the context of Java 1.5, because it actually
mentions Object.

Object was only necessary without generics, now we can use type
parameters.

Angelika Langer has something to say on the matter:
http://www.angelikalanger.com/Gener...ment the clone method of a parameterized type

Cloning is very often not what you want anyway, as it is shallow
copying.

Serialising and deserialising tends to be more thorough, but very
wasteful. I'd rather avoid 'magic' behaviour, and write an explicit
copy constructor or factory method, which is the approach the Java
collections APIs take.

Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,182
Latest member
BettinaPol

Latest Threads

Top