I do not know if the question is well written but this is the question.
I have my class ProductosLacteos
. When I create the instance I do this:
ProductosLacteos quesito = new ProductosLacteos();
Then I want to get quesito
as a text string. For what? Question of debugging. I have a console where different program data are shown, but the plan is that within ProductosLacteos
you can access the name of the instance with getNombreDeLaInstancia()
. This is what I hope:
ProductosLacteos quesito = new ProductosLacteos();
ProductosLacteos lechita = new ProductosLacteos();
ProductosLacteos jocoque = new ProductosLacteos();
System.out.println(quesito.getNombreDeLaInstancia());
System.out.println(lechita.getNombreDeLaInstancia());
System.out.println(jocoque.getNombreDeLaInstancia());
And I get results:
"quesito"
"lechita"
"jocoque"
Is it possible to access this data with extends
so that you have it available for all my classes?
Thank you!