1public class CopyConstructorExample {
2
3 private int someInt;
4 private String someString;
5 private Date someDate;
6
7 public CopyConstructorExample(CopyConstructorExample example) {
8 this.someInt = example.getSomeInt();
9 this.someString = example.getSomeString();
10 this.someDate = new Date(example.getSomeDate().getTime());
11 // We need to construct a new Date object, else we would have the same date object
12 }
13
14 // Other Constructors here
15 // Getters and Setters here
16}
17public class UsageExample {
18 public static void main(String[] args) {
19 CopyConstructorExample example = new CopyConstructorExample(5, "Test");
20 // Copy example using the Constructor
21 CopyConstructorExample copy = new CopyConstructorExample(example);
22
23 }
24}