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 Postprotected native Object clone() throws CloneNotSupportedException;
Notice the
native
keyword. This means that the method is not implemented using Java, but using native code (C/C++) using the Java Native Interface (http://java.sun.com/docs/books/jni/).
Jump to PostHow many other methods are native? I'll bet a lot.
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.