In Java, how to access an object field decided at runtime?
22:51 03 Aug 2012

In JavaScript you can reference an object's properties using either dot notation, or bracket notation. This can be useful by using a string variable such as:

var myObject = { hello: "world" };
var prop = "hello";

// both will output "world".
console.log( myObject[ prop ] );
console.log( myObject.hello );

Is there a similar syntax in java to access an objects properties using a string variable, similar to javascript's bracket notation?

java