• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

using finalize() method

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey!
concept of finalize() method is well understood, but how do we actually go about using it.
Firstly it is protected, so how do i use it.
when i declare it in my class like:
protected void finalize() {
try{
System.out.println("Garbage to be collected");
}
catch(Throwable t)
{}
it gives me error.
please help me with this.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see any problem with your code. (Except for unbalanced parantheses) I did try and run your code in my program and it did execute.
Access modifier protected should not trouble you. It only says if classes B and C inherit from A, you cannot call finalize on B in class C.
Can you be more specific about the problem you are facing?
 
reply
    Bookmark Topic Watch Topic
  • New Topic