android - Access Java anonymous object properties -
android - Access Java anonymous object properties -
i relatively new java programming, trying access anonymous objects properties, object:
object tomorowweekday = convertedtimeforandroid(openhours, tomorrow);
inspected via debugger, looks this:
i need access key value pair "to" , "from", there no method such tomorrowweekday.get("from")
.
how access these values in anonymous object?
change to
jsonobject tomorowweekday = convertedtimeforandroid(openhours, tomorrow);
you're setting declared type object
. means can't see methods other ones exposed object
, though actual type jsonobject
. create declared type same actual type , you'll able see methods need.
because jsonobject
subclass of object
(as indeed every class is), current code legal, means abstract away functionality isn't nowadays in object
. useful trick, not 1 employ unless know why you're doing it.
(as side note, word anonymous not quite appropriate here. isn't anonymous: name tomorrowweekday
.)
java android
Comments
Post a Comment