fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static final int ID_IMAGE = 1;
  11. public static final int ID_BOOL = 2;
  12. public static final int ID_BOTH = 3;
  13.  
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. Ideone me = new Ideone();
  17. me.init(Ideone.ID_IMAGE);
  18. me.init(Ideone.ID_BOOL);
  19. me.init(Ideone.ID_BOTH);
  20. }
  21.  
  22. public void init( int boxID ) {
  23. System.out.println("inside INIT with boxId=" + boxID);
  24. initComponentText();
  25.  
  26. if ((boxID & ID_IMAGE) == ID_IMAGE) initComponentImg();
  27. if ((boxID & ID_BOOL) == ID_BOOL) initComponentBool();
  28. }
  29.  
  30. private void initComponentImg() {
  31. System.out.println("Creating IMG");
  32. }
  33.  
  34. private void initComponentBool() {
  35. System.out.println("Creating BOOL");;
  36. }
  37.  
  38. private void initComponentText() {
  39. System.out.println("Creating TEXT");
  40. }
  41.  
  42. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
inside INIT with boxId=1
Creating TEXT
Creating IMG
inside INIT with boxId=2
Creating TEXT
Creating BOOL
inside INIT with boxId=3
Creating TEXT
Creating IMG
Creating BOOL