I wanted to know how Java does Object Cloning. But when I read the Object.java class I saw that it was not defined in it. Im confused. I really dont know who internals of java are implemented. It would be nice if someone could help me with this.....
stevanity 4 Posting Whiz in Training
Recommended Answers
Jump to PostHow many other methods are native? I'll bet a lot.
Jump to PostWhat doc are you getting that from?
My API doc has this:
protected Object clone()Just open the class in IDE and get source (that is how it does work in IntelliJ), then you can see internal structure :)
Jump to PostAdding on to others, it also pays to know that cloning in Java is pretty much broken and for practical purposes you are better off using other alternatives (hand rolled copy constructor).
All 10 Replies
nmaillet 97 Posting Whiz in Training
NormR1 563 Posting Sage Team Colleague
nmaillet 97 Posting Whiz in Training
NormR1 563 Posting Sage Team Colleague
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
stevanity 4 Posting Whiz in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
stevanity 4 Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.