Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public class Global {
  2. public static final Item ITEM;
  3. public static final int CONST_1 = 0xdeadbeef;
  4.  
  5. static {
  6. System.out.println("Global {static} -> Before Item Initialization");
  7. ITEM = new Item();
  8. System.out.println("Global {static} -> After Item Initialization");
  9. }
  10. }
  11.  
  12. public class Item {
  13. public static final Item INSTANCE = Global.ITEM;
  14. public static final int CONST_2 = 0xdeadbeef;
  15.  
  16. public Item() {
  17. System.out.print("Item() -> INSTANCE = " + INSTANCE);
  18. System.out.print(", CONST_1 = " + Integer.toHexString(Global.CONST_1));
  19. System.out.println(", CONST_2 = " + Integer.toHexString(CONST_2));
  20. }
  21. }
  22.  
  23. Global {static} -> Before
  24. Item() -> INSTANCE = null, CONST_1 = deadbeef, CONST_2 = beefdead
  25. Global {static} -> After
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement