Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Monday

JAVA PROGRAMMING TUTORIAL 35 : BitSet

//BitSet class implements a vector of bits that grows as needed
//Each component of the bit set has a boolean value
//The bits of a BitSet are indexed by nonnegative integers

import java.util.BitSet;

public class HackDefence {

       public static void main(String args[]) {

              BitSet firstBits = new BitSet(10);

              BitSet secondBits = new BitSet(10);
     
              for(int i=0; i<10; i++) {

                   if((i%3) == 0)

                       firstBits.set(i);

                   if((i%4) != 0)

                       secondBits.set(i);

              }

             System.out.println("firstBits: " + firstBits);

             System.out.println("secondBits: " + secondBits);

             secondBits.and(firstBits); //secondBits.and(firstBits) ands the contenst
   
            System.out.println("firstBits AND secondBits: " + secondBits);

      }

}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...