运行时对象字段值访问 [英] Run time object field value access

查看:72
本文介绍了运行时对象字段值访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<b></b>hi,
i have function getValues(Object object) which perform some operation. and run time i can pass any object to it. I have to access public fields of that object with there values.
so how to do this?

Thanks,
pankaj

推荐答案

你可以使用java Reflection来做到这一点。
You can do this by using java Reflection.


使用java反射我可以访问字段名称但是如何访问字段值?
using java reflection i can access field name but how to access field value?


如果你得到字段,那么你可以很容易地得到字段值。 br />
这是一个例子试试这个
If you get the field then you can get the field value easily.
Here is some example Try this


这篇关于运行时对象字段值访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆