Welcome To The World Of Hacking


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

Tuesday

JAVA PROGRAMMING TUTORIAL 36 : OR LOGIC USING BitSet

//First of all go to this link if you are new visitor JAVA PROGRAMMING TUTORIAL 35 : BitSet

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.or(firstBits); //secondBits.or(firstBits) ORs the contenst
 
              System.out.println("firstBits OR secondBits: " + secondBits);
   
       }

}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...