Bitwise Operator Example
class bitwise
{
public static void main(String args[])
{
int a=22,b=10,and,or,comp,xor,rs,ls;
and=a&b;
or=a|b;
comp=~a;
xor=a^b;
rs=a<<2;
ls=a>>2;
System.out.println("and "+and);
System.out.println("or "+or);
System.out.println("comp "+comp);
System.out.println("xor "+xor);
System.out.println("rs "+rs);
System.out.println("ls "+ls);
}
}
class bitwise
{
public static void main(String args[])
{
int a=22,b=10,and,or,comp,xor,rs,ls;
and=a&b;
or=a|b;
comp=~a;
xor=a^b;
rs=a<<2;
ls=a>>2;
System.out.println("and "+and);
System.out.println("or "+or);
System.out.println("comp "+comp);
System.out.println("xor "+xor);
System.out.println("rs "+rs);
System.out.println("ls "+ls);
}
}
0 comments:
Post a Comment