/* Example of Bitwise Operator */
package Bitwise;
public class Bitwise
{
public static void main(String[] args)
{
int Op1 = 5, Op2 = 10;
int BitwiseOR, BitwiseAND;
int LSvalue, RSvalue, RSzerofill;
BitwiseOR = Op1 | Op2;
BitwiseAND = Op1 & Op2;
prln("Bitwise OR of " + Op1 + " and " + Op2 + " is: " +BitwiseOR);
prln("Bitwise AND of " + Op1 + " and " + Op2 + " is: " +BitwiseAND);
LSvalue = Op2<<2;
prln("2 times left shift of " +Op2+ " is: " +LSvalue);
RSvalue = Op2>>2;
prln("2 times right shift of " +Op2+ " is: " +RSvalue);
RSzerofill = Op2>>>2;
prln("2 times right shift with zero fill of " +Op2+ " is: " +RSzerofill);
}
static void prln(Object anyObject)
{
System.out.println(anyObject);
}
static void pr(Object anyObject)
{
System.out.print(anyObject);
}
}
0 comments:
Post a Comment