title: Correct usage of bitmask?
body: <p>heyhey,
  just have a question about bitmasks. I think I know now what they are and where they can be used.
  I want to store specific permissions like BUILD, BREAK and INTERACT and maybe more for specific groups. The code below should do this but Im not very sure whether this is the corrent "style".</p>
  
  <p>The idea is to use the first 3 bits here to store the permissions of the first group, then use the next three bits for the second group and so on.
  So my question is now whether this is a good way or not or what would be better?</p>
  
  <pre><code>public class Test {
      private int permissions = 0;
  
      /**
       * The amount of permissions, currently: {@link #BREAK}, {@link #BUILD}, {@link #INTERACT}
       */
      private static final int PERMISSIONS = 3;
      /**
       * The different permissions
       */
      public static final int BUILD = 1, BREAK = 2, INTERACT = 4;
      /**
       * The different groups
       */
      public static final int ALLIANCE = 0, OUTSIDERS = 1;
  
      public void setPermissions(int permissions, int group)
      {
          this.permissions = permissions &lt;&lt; group * PERMISSIONS;
      }
  
      public void addPermissions(int permission, int group)
      {
          setPermissions(this.permissions | permission, group);
      }
  
      public boolean hasPermission(int permission, int group)
      {
          return (permissions &amp; permission &lt;&lt; group * PERMISSIONS) == permission;
      }
  }
  </code></pre>
  
  <p>EDIT: I want to use as little memory as possible because I'll need to store much data.</p>
  
  <p>EDIT: I also need to store it in a sql database, but it should not make probs.</p>