is it possible to get an object from his reference id?
i get a list of String containing the reference id of an object like:
com.test.test.business.model.Gamma@20
how to get the object from this reference id?
it’s only a string and it isn’t castable to the object itself
What you see is called the default toString of an object. It is an amalgamation of the FQCN (fully qualified class name) of the class it belongs to and the hashCode of the object.
Quoting from the JavaDoc of toString:
In short, you can’t get an object using this reference id.
We can override
toStringto give a more human readable output. Take a look at the below two classes, with and withouttoString. Try to execute the main method and compare the output of the two print statements.However, if you are really looking for a way to persist objects and resurrect them at a later stage, you should read up on Serialization.