ascii char representation in Java?
<p>If I use a single int to represent an ascii character set, how is using it reducing the storage space by a factor of 8 ? as compared to an array of 256 boolean values ? The single int is also functioning like a bit vector. </p>

<p>A boolean in java will occupy 1 bit as it can represent only true or false values. So for example if i have an array of boolean values. boolean[] char_set = new boolean[256] This will occupy 256 bits correct ? I'm reading that if i use a single int like a bit vector which means I can use 32 bits to cover 256 values. I guess that is reduction by a factor of 8. But why does the code below work ? </p>

<p>It is checking if there are any duplicates in the string. They are assuming an ascii char set. Str is some string. </p>

<pre><code>int checker = 0;
for(int i=0;i&lt;str.length();i++)
{
  int val = str.charAt(i) - 'a';
  if(checker&amp; (1&lt;&lt;val)) &gt; 0)
  {
     return false;
  }
  checker |= (1&lt;&lt;val);
}
  return true;
}
</code></pre>

<p>Can someone particularly explain how the bit vector logic works in this case. They are assuming the string contains lowercase characters. </p>
