A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
  • Newsletters

cloneable

A collection of 1 posts
Cloneable, a Java design gotcha
Java

Cloneable, a Java design gotcha

Some time ago, I described a couple of surprising design choices in the JDK functional interfaces API. Lately, during a lesson, a student of mine proposed to shallow-copy an ArrayList by using the clone() method: I thought this is another API gotcha worth writing about. Cloning an object means a new object is created with the same state as the original one. As per the JavaDoc: Creates and returns a copy of this object. The precise meaning of 'copy' may depend on the class of the object.

Oct 14, 2018
A Java geek © 2008-2026
v. 0c74272de1a829b7547f871650d5e63f6445b161/13697367144
Latest Posts