![]() |
The Java Developers Almanac 1.4 |
|
e115. Getting and Setting the Value of a FieldThis example assumes that the field has the typeint.
try {
// Get value
field.getInt(object);
// Set value
field.setInt(object, 123);
// Get value of a static field
field.getInt(null);
// Set value of a static field
field.setInt(null, 123);
} catch (IllegalAccessException e) {
}
© 2002 Addison-Wesley. |