Manipulating the BitSet : BitSet : Collections Data Structure : Java examples (example source code) Organized by topic

Java
C++
PHP


Java  »  Collections Data Structure   » [  BitSet  ]  Screenshots 
 



Manipulating the BitSet



import java.util.BitSet;

public class TwoBitPlanets {
  public static void main(String args[]) {
    String names[] "Mercury""Venus""Earth""Mars""Jupiter",
        "Saturn""Uranus""Neptune""Pluto" };
    int moons[] 00121618178};
    int namesLen = names.length;
    BitSet bits = new BitSet(namesLen);
    for (int i = 0; i < namesLen; i++) {
      if ((moons[i2== 0) {
        bits.set(i);
      }
    }
    for (int i = 0; i < namesLen; i++) {
      System.out.println(names[i" Even # Moons (" + moons[i")? "
          + bits.get(i));
    }
  }
}
           
       
Related examples in the same category
1.  Java 1.5 (5.0) Changes to the API: several of the new bit manipulation methods in Integer. Java 1.5 (5.0) Changes to the API: several of the new bit manipulation methods in Integer.
2.  The use of BitSet The use of BitSet
3.  Another Bitset demo Another Bitset demo
4.  Operations on series of numbers
5.  BitOHoney
6.  BitOps
























Home| Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.