// code to illustrate using reflection to change data at runtime import java.lang.reflect.Field; class Student { private String firstName = "Sampath"; } public class TestReflection { public static void main(String args[]) throws Exception { Student someStudent = new Student(); Field fs = someStudent.getClass().getDeclaredField("firstName"); fs.setAccessible(true); System.out.println("Value of " + fs.getName() + ": " + fs.get(someStudent)); fs.set(someStudent, "Trisha"); System.out.println("Value of " + fs.getName() + " after changing: " + fs.get(someStudent)); } } // OUTPUT: //Value of firstName: Sampath //Value of firstName after changing: Trisha // this feature is useful in serialization, support for FXML, etc.