public static void main(String[] args) { Student s1 = new Student(); s1.name = "홍길동"; s1.tel = "111-1111"; s1.workState = Working.WORK; s1.location = Location.KANGNAM; s1.subject = CatSubject.JAVA; }
public static void main(String[] args) throws CloneNotSupportedException { Student s1 = new Student("홍길동", "111-1111", false); Student s2 = (Student) s1.clone(); // 1) 일반적인 복제 Student s3 = new Student("", "", false); s3.name = s1.name; s3.tel = s1.tel; s3.gender = s1.gender; System.out.println(s1); System.out.println(s2); if (s1 == s2) System.out.println("s1 == s2"); System.out.println("-------------------"); }