• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Access a Class Field by using Reflection?  RSS feed

 
Mohan Patidar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii Rancher Any One can Help.......

i have these MyClass




and i want to access int and String field in Below class By using Reflaction.....

 
Jigs Gohil
Greenhorn
Posts: 6
Eclipse IDE jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see if this helps...

 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question too difficult for "beginning". Moving.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getFields only returns the visible fields, but also those of any class higher in the hierarchy.
getDeclaredFields returns all fields, both visible and invisible, but only those declared in the class itself, not those declared in any class higher in the hierarchy.
 
Mohan Patidar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jigs Gohil , Campbell Ritchie and Rob Spoor .... i got my point.....

Is it possible to access a local field of other class method using reflaction...??

like

public void getData()
{
public int age;
}



 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, have you tried it?
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's a local field? I don't think there is such a thing.
Have a look at the Method class and see whether it has any method for accessing local variables.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and . . .
You're welcome
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!