public class CopyObject2 { public static void main(String[] args) { BankAccount a = new BankAccount( ); // Object a a.accNum = 123; a.name = "John"; a.balance = 1000; BankAccount b; // The copy b = new BankAccount( ); // Create a new object b.accNum = a.accNum; // Copy old values over b.name = a.name; // to the new object b.balance = a.balance; /* ==================================== Let's do the experiment again.... ==================================== */ /* ---------------------------------- Print the values before the update ---------------------------------- */ System.out.println("Object a: " + a.convToString()); System.out.println("Object b: " + b.convToString()); b.accNum = 789; // Update the COPY b.name = "Jess"; // (must NOT change the original) b.balance = 5000; // /* ---------------------------------- Print the values after the update ---------------------------------- */ System.out.println("Values after updating the copy b.balance:"); System.out.println("Object a: " + a.convToString()); System.out.println("Object b: " + b.convToString()); } }