星期三, 五月 09, 2007

How to access private fields through reflect?

sample code :
A a = new A("Hello Vincent");
Field field = a.getClass().getDeclaredField("a");
field.setAccessible(true);
System.out.println(field.get(a).toString());

星期二, 五月 01, 2007

Design Patterns - Null Object Pattern

This pattern offen eliminates the need to check for null , and it can help to simplify the code.





Design Patterns - Visitor Pattern

Use the Visitor Pattern when you want to add capabilities to a composite of objects and encapsulation is not important.