Only the underlying built-in element = deep copy (string not) you define the class if you need a deep copy, to rewrite Cloneable's Clone method if the inheritance relationship, the parent class will also be rewritten. Http://www.cnblogs.com/yxnchinahlj/archive/2010/09/20/1831615.html① Why do we have to call Super.clone () when we override the Clone () method of object in a derived class? At run time, Clone () in object identifies which object you want to copy, then allocates space for the object, replicates the object, and copies the contents of the original object one by one into the storage space of the new object.
②the Clone () method that inherits from the Java.lang.Object class is shallow copy.
Http://bbs.csdn.net/topics/360077763http://zhidao.baidu.com/link?url=UktuJvqqUbe3BJcy4nlNoee09gZfGBIB_ Sdvvrcbfjn8hdodswcbi8onllcdqp4cmfvm9wvz3xfvnxn3bz_foa
The comparator wants to override the Compare method in the comparator interface import Java.io.*;import Java.net.*;import java.util.*;
public class test{public static void Main (String args[]) throws exception{treemap<string,integer> mm=new treemap& Lt String,integer> (New Comparator () {public int compare (Object A,object b) {string aa= (string) A; String bb= (string) b; return Bb.compareto (AA); } }); Mm.put (New String ("a"), new Integer (23)); Mm.put ("B", New Integer (31)); Set<map.entry<string,integer>> Set=mm.entryset (); SYSTEM.OUT.PRINTLN (set); System.out.println (Mm.keyset ()); }}
java-deep copy/Shallow copy Comparator