Please friends could you tell me if this looks right? I understood more or less the garbage collector but I want to test in practice.Topic Java


This Content is from Stack Overflow. Question asked by Valentin Georgiev

Below is example with cats method.Is this looks right?

 public class Objects{
    //when an object has been dereferenced 
    public void cats(){
      System.out.println("wet food!");
    public static void main(String[]args){
     Objects.myCatwants = new Objects();
     System.out.println("end of method");//out cats method is ready for garbage collection


Thank you very much in advance!


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?