Skip to content

Instantly share code, notes, and snippets.

@komu
Created April 1, 2017 05:36
Show Gist options
  • Save komu/dcc1bb36141c104297e5ed7b6dea0e85 to your computer and use it in GitHub Desktop.
Save komu/dcc1bb36141c104297e5ed7b6dea0e85 to your computer and use it in GitHub Desktop.
package orwell;
import java.lang.reflect.Field;
public class Room101 {
public static void main(String[] args) {
Integer result = 2 + 2;
System.out.printf("2 + 2 = %d\n", result);
room101();
System.out.printf("2 + 2 = %d\n", result);
}
private static void room101() {
try {
Integer four = 4;
Field field = four.getClass().getDeclaredField("value");
field.setAccessible(true);
field.set(four, 5);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment