Java - Object Oriented Programming
Classes
public class Animal {}
Garbage Collection
- While Java has automatic garbage collection, there is a keyword that can be used to clean up stuff semi-manually. When an object reference, the class that was used can use the function finalize() to clean up anything else.
- The Object class has a default finalize() that can be overrode. Since every class inherits from the Object class, finalize() can be used by any Java object.
class A
{
int i = 50;
@Override
protected void finalize() throws Throwable
{
System.out.println("From Finalize Method");
}
}