Commit 6aa6d68b authored by michael lundquist's avatar michael lundquist
Browse files

About to delete this code. Clone is protected in Java's Cloneable interface, so it doesn't work.

parent 36ad56bf
......@@ -4,26 +4,34 @@ import java.util.Arrays;
import java.util.Random;
public class Examples{
public static void main(String[] args){
//CustomS_B[] vars = {new Examples.CustomS_B("abc"),new Examples.CustomS_B("DEF"),new Examples.CustomS_B("ghi")};
Integer[] vars = {1,2,3,4};
public Object[] deepClone(Object[] o){
Class oType = o.getClass();
Object[] newClone = Array.newInstance(oType, o.length);
for(int k=0; k < contacts.length; k++){
Method clone = o[k].getMethod("clone", new Class[0]);
newClone[k] = (Object) clone.invoke(obj, args);
}catch(NoSuchMethodException e){
* A way of cloning an array of clonables.
* Works with multi dimensional arrays
public static Integer[] deepClone(Integer[] o){
//Class oType = o.getClass();
//Cloneable[] newClone = o.clone();//Array.newInstance(oType, o.length);
Integer[] newClone = o.clone();
for(int k=0; k < o.length; k++){
newClone[k] = deepClone((Integer[]) o[k]);
Cloneable newObj = o[k];
newClone[k] = newObj.clone();
return newClone;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment