File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes finallizer() & clone method are protected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "finallizer() & clone method are protected" Watch "finallizer() & clone method are protected" New topic
Author

finallizer() & clone method are protected

Manish Thapliyal
Greenhorn

Joined: Aug 07, 2007
Posts: 17
why the finallizer() & clone method are protected . why not public or private
Please explain.


Manish
amitabh mehra
Ranch Hand

Joined: Dec 05, 2006
Posts: 98
Manish, you can check this thread for the same:why is finalize() protected
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
Some people would suggest avoiding clone() altogether.

An old thread will give some more detail on clone().

The default implementation will throw an exception - no need for anyone to call it. If you override it, you can make it public.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Bill Shirley:
Some people would suggest avoiding clone() altogether


... and others would suggest avoiding finalize() altogether, too.

Both finalize() and clone() are relics from the very earliest days of Java. They aren't as well thought-out as later features. Luckily, extremely few programs really need finalize() [use weak or phantom references instead], and few need clone().

I consider cloning of arrays to be a special case. It's the most efficient way to copy a whole array, and there are no confusions with how to override the array-cloning method, because you can't.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finallizer() & clone method are protected
 
Similar Threads
Object class method access specifier
about core java
about core java
By using Cloneable Method
Cloning