There is no similar syntax in java or any direct way to do this.
java provides a reflection API that allows you to query object properties / interface at runtime using Strings , which represent, for example. object properties and methods.
You can also save (key, value) properties in the data structure, such as HashMap , matching Strings with objects.
source share