Beginner's Question: Create an identical object.



Hi all

Need help in understanding this.

Let's say I have 2 class. driver class, and customer class.

In driver class,

[code]

Customer CustA = new Customer(Name, Age);

[/code]

This will create a CustA object.
If I do this...

[code]

Customer CustB = CustA

[/code]

It is actually pointing CustB to CustA, am I right to say that CustA and
CustB is the same object in the memory?

So if yes.

[code]

Customer CustB = new Customer(CustA.getName(), CustA.getAge());

[/code]

Will it work and create another Customer object CustB with the same
attributes of CustA, can it be consider a clone of CustA?


.



Relevant Pages