Saturday, January 10, 2009

Java Reflection : Setting values to Private Members.

Just something that I found out today on reflection : How do you set a value to private members using reflections in java.
Well, you do it using Field.setAccessible(true) method.

Eg:
FunckyClass fc = new
FunckyClass();
Field fl
=
FunckyClass.class.getDeclaredField("testProp");
System.out.println(" f1 :
"+fl);

fl.setAccessible(true);
fl.set(fc, "(Test
Value)");

fc.printTestProp();

Wednesday, August 27, 2008

About Me.

Guru Prasad G.V - Senior Software Developer @ XProtean
We make retail software products. One of them is soon to hit the markets in a big way :) Watch this space for more on it ...
 
Free Domains Hosting at .co.nr