I've got a problem...
I want to copy any object.... So that I've got two Objects of the same class...
How can I manage it, without knowing before, which class it is?


1 2 3 | if (thisObject isInstanceof Class) { Class newX = new Class(); } |
1 2 3 4 | public interface Copy { Copy duplicate(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | public class Example extends Actor implements Copy { private String ExampleName; [...] public Copy duplicate() { Example Exe = new Example(); Exe.ExampleName = this .ExampleName; [...] return Exe; } } |
1 2 3 4 | public Copy getACopyOfTheObject(Copy ObjectToCopy) { return ObjectToCopy.duplicate(); } |