Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33241
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2015-11-29 23:00 -0800 |
| References | <n31vi5$dkg$1@speranza.aioe.org> |
| Message-ID | <69276629-2d13-49de-a8de-09dcfa4f7341@googlegroups.com> (permalink) |
| Subject | Re: Why it necessary to implement clonealbe interface? |
| From | Lew <lewbloch@gmail.com> |
Xue Feng wrote:
> A class has to implement cloneable interface, otherwise its object can
> not be cloned. IMO, it is enough that a class clone itself by inheriting
> the clone method from Object class. It is somewaht reduntant to
> implement cloneable interface. Actually, there is nothing in cloneable
> interface. Namely, it is defined as follows:
>
> interface cloneable {
> }
>
> I wonder the reason for this design. Any explanation? Thanks.
There is no 'cloneable' interface in the standard Java API.
The reason for the requirements of 'Cloneable' that are similar to your question is to prevent cloning except where it's actually wanted, but have the mechanism in place from the very root of the object hierarchy so it is available for such use.
--
Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
Why it necessary to implement clonealbe interface? Xue Feng <xf.lotus@yahoo.com> - 2015-11-24 23:28 +0800
Re: Why it necessary to implement clonealbe interface? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-24 11:03 -0500
Re: Why it necessary to implement clonealbe interface? Arne Vajhøj <arne@vajhoej.dk> - 2015-11-24 19:49 -0500
Re: Why it necessary to implement clonealbe interface? Eric Douglas <e.d.programmer@gmail.com> - 2015-11-25 11:01 -0800
Re: Why it necessary to implement clonealbe interface? Arne Vajhøj <arne@vajhoej.dk> - 2015-11-25 16:41 -0500
Re: Why it necessary to implement clonealbe interface? Lew <lewbloch@gmail.com> - 2015-11-29 23:00 -0800
csiph-web