Re: boolean array
 
John W. Kennedy wrote:
sdlt85@gmail.com wrote:
Hi, these are the only two ways to declare a boolean array of values
1) boolean setA[] = new boolean [101];
    setA[3]=true;
    setA[5]=true;
    setA[10]=true;
    setA[13]=true;
    setA[16]=true;
    setA[23]=true;
    setA[30]=true;
    setA[35]=true;
    setA[56]=true;
    setA[89]=true;
2) boolean arraySetB[] = {false, true, false, false, false, false,
false, true, true, false, true, false, false};
3) boolean arraySetC[] = new boolean[25];
   {
      int mask = 0x00348AD4;
      int i = 0;
      while (mask != 0) {
         if ((mask & 1) !- 0)
            arraySetC[i] = true;
         mask >>>= 1;
         ++i;
      }
   }
4) boolean arraySetD[] = new boolean[20];
   {
      final int[] init = {2, 3, 5, 7, 11, 13, 17, 19};
      for (int i = 0; i < init.length; ++i)
         arraySetD[init[i]] = true;
   }
n, m, x)
public class Foo implements java.io.Serializable
{
  static final long serialVersionUID = 17L;
  private final boolean [] truths;
  public Foo( boolean [] beliefs )
  {
    truths = beliefs.clone();              // throws NPE
  }
  public Foo( Boolean [] beliefs )
  {
    truths = new boolean [beliefs.length]; // throws NPE
    for ( int ix = 0; ix < truths.length; ++ix )
    {
        truths [ix] =  beliefs [ix];       // throws NPE
    }
  }
  public Foo( List <Boolean> beliefs )
  {
    this( beliefs.toArray( new Boolean [0] )); // throws NPE
  }
  public boolean [] getTruths()
  {
   return truths.clone();
  }
  private void readObject( java.io.ObjectInputStream in )
      throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
  }
}
-- 
Lew