如可方便的克隆一个对象
1 package com.tj; 2 3 public class MyClass implements Cloneable { 4 5 public Object clone() { 6 Cloneable theClone = new MyClass(); 7 // 初始化 8 return theClone; 9 } 10 11 public static void main(String[] args) { 12 MyClass myObject = new MyClass(); 13 MyClass myObjectClone = (MyClass) myObject.clone(); 14 15 // 数组是自动可复制的 16 int[] ints = new int[] {123,456}; 17 int[] intsClone = ints.clone(); 18 } 19 }