Copy of a class

D

David McCallum

I load a class from a database table

I want to get assign and exact copy of the class, e.g. class2=class1

The reason is I want to know if any changes were made to class1. Along the
lines of Delphi's class2.Assign(class1);

TIA

David McCallum;
 
J

John C. Bollinger

David said:
I load a class from a database table

I want to get assign and exact copy of the class, e.g. class2=class1

The reason is I want to know if any changes were made to class1. Along the
lines of Delphi's class2.Assign(class1);

Do you really mean you want to load a class and work with the
corresponding Class object, or do you mean you want to load an instance
of some class and work with that?

What does the Delphi statement do?

On the off chance that I have correctly guessed the answers to both
questions, I will offer that Java provides no generic way to copy the
state of one object to another. (And that's a _good_ thing.) The
objects' class would have to expose a suitable method for performing
such an operation in order to make it possible, in which case you would
accomplish your goal by invoking the method, similar to the Delphi
statement.


John Bollinger
(e-mail address removed)
 
N

nos

i was just reading last night about "clone"
isn't clone appropriate to make an exact copy of a class
 
M

Michael Borgwardt

nos said:
i was just reading last night about "clone"
isn't clone appropriate to make an exact copy of a class

Only if the author of the class explicitly "allowed" it by implementing
Cloneable and exposing a public clone method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top