the Object class's clone method

hi

Im writing a clone method for my Student class. what I see from goggling is that I need to call " Student cloned = (Student) super.clone(); " this is the first statement in my clone method and I really dont know what it does.

I looked into the Object class and found that it didnt have any impletation it was " protected native Object clone() throws CloneNotSupportedException; " what I found out of it was that the method returned an Object object so it needed to be casted and it throwed an checked exception so I should mention it in my Student method head. But what I don't understand is why I need to call this super.clone method if my class extends from Object. What does the clone method of the object class do?

[743 byte] By [superdepora] at [2007-11-27 9:57:55]
# 1
> I looked into the Object class and found that it> didnt have any impletation It does have an implementation, but the implmentation is in native code. I believe if you read the docs, you'll find that it does a field-by-field copy.
jverda at 2007-7-13 0:28:20 > top of Java-index,Java Essentials,New To Java...
# 2
ohhh thank you I didnt know what native meant, I will read it when Im on volume II, Im reading Core Java volume I right now :D
superdeportivoa at 2007-7-13 0:28:20 > top of Java-index,Java Essentials,New To Java...
# 3

> ohhh thank you I didnt know what native meant, I will

> read it when Im on volume II, Im reading Core Java

> volume I right now :D

Native just means code that is executed directly by the OS, such as a 'C' compiled binary

BTW, there's no need to sign up another account for each post :p

georgemca at 2007-7-13 0:28:20 > top of Java-index,Java Essentials,New To Java...