• Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing private member of super class in subclass in java

 
saket gupta
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got the problem to accessing the private member or method of super class
in subclass in java you can not access it but using some reflection or disable to security manager we can do that.
but i am not getting how to do this please tell me solution for that

thanks
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why cant you use a proctected scope ?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ November 09, 2004: Message edited by: Pradeep Bhat ]
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace PrivateField with your private filed member avar.

Please post in public forum rather than sending PM to me.
 
saket gupta
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...

dear pl...tell me how can i access all private member from super class in sub class

with the help of this code u can access only specific variable
but i want to store all private instance variable in Field [] array then i want to use them

pl.. solve the problem
 
saket gupta
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...

dear pl...tell me how can i access all private member from super class in sub class
=============
Field field = class.getDeclaredField("avar");
field.setAccessible(true);
System.out.println("*******Private String :" + field.get(obj))
==============
with the help of above code u can access only specific variable
but i want to store all private instance variable in Field [] array then i want to use them

pl.. solve the problem
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!