Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31749
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2015-05-28 23:48 -0700 |
| References | <646d1d0e-4c63-439f-840c-3c4421e7bc15@googlegroups.com> |
| Message-ID | <2ecb0338-074f-431d-8aea-c20e5f16ff93@googlegroups.com> (permalink) |
| Subject | Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? |
| From | HU Tiange <pigeon.tian@googlemail.com> |
On Friday, May 29, 2015 at 1:07:30 AM UTC+2, HU Tiange wrote:
> I find a question from stackoverflow, what is I want to ask,
>
> http://stackoverflow.com/questions/13092128/why-to-override-clone-method-in-java
>
>
> Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin?
>
> One Comment say that :
>
> " For invoking any method of super class you need an instance of that class. Now, if you override the clone method, you have that instance of Object class as super. So, you use super.clone() to invoke it."
>
> That is to say, we must do such things?
> But:
> class Animal
> {
> void A(){};
> }
>
> class Dog extends Animal
> {
>
> }
>
> main method:
> Dog dog = new Dog();
> dog.A;
>
> It works, I do not invoke some super class methods.
> Why in clone situation, we need?
But all objects are subclasses of Objects, why it can not be directly called?
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? pigeon.tian@googlemail.com - 2015-05-28 16:07 -0700
Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? Arne Vajhøj <arne@vajhoej.dk> - 2015-05-28 20:50 -0400
Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? HU Tiange <pigeon.tian@googlemail.com> - 2015-05-28 23:48 -0700
Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-29 08:24 -0400
Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? Arne Vajhøj <arne@vajhoej.dk> - 2015-06-03 20:41 -0400
Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? Lew <lewbloch@gmail.com> - 2015-06-19 16:45 -0700
Re: Why do we need to "@Override Object clone" if all classes are subclasses of Object, why can not directly involke the functin? HU Tiange <pigeon.tian@googlemail.com> - 2015-05-28 23:49 -0700
csiph-web