27 September, 2020

Write a java program for Garbage Collection.

garbage collection,java (programming language),java garbage collection,garbage collection,g1 garbage collector,garbage-collection,java tutorial,java garbage collection tutorials,understanding java garbage collection,programming,exam
class GC
{
	static int count;
	GC()
	{
		count++;
		System.out.println(count+"Object Created");
	}
	public static void main(String arg[])
	{
		GC ob1=new GC();
		GC ob2=new GC();
		GC ob3=new GC();
		{
			GC ob4=new GC();
		}
		GC ob5=new GC();
		ob5=ob1;
		System.gc();
	}
	@Override
	protected void finalize()
	{
		count--;
		System.out.println(count);
	}
}
24
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post