0% found this document useful (0 votes)
5 views3 pages

Java-U-1-Lec-4-Code-java-pdf

Uploaded by

mk5780381
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Java-U-1-Lec-4-Code-java-pdf

Uploaded by

mk5780381
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

class OperatorsDemo

public static void main(String args[])

int a=15, b=8;

System.out.println(a+b);

System.out.println(a-b);

System.out.println(a*b);

System.out.println(a/b);

System.out.println(a%b);

System.out.println(+a);

System.out.println(-a);

System.out.println(++a);

System.out.println(--a);

System.out.println(a==b); //False

System.out.println(a!=b); //True

System.out.println(a>b); //True

System.out.println(a<b); //False

System.out.println(a>=b); //True

System.out.println(a<=b); //False

System.out.println((a>b)&&(b>5));

System.out.println((a>b)||(b<5));

System.out.println(!(a>b));

a=5;

b=3;
int c=8;

int d=1;

System.out.println(a&b);

System.out.println(a|b);

System.out.println(a^b);

System.out.println(~a);

System.out.println(c<<d);

System.out.println(c>>d);

System.out.println(-c>>>d);

c+=2; //c=c+2

System.out.println(c);

c-=2; //c=c-2

System.out.println(c);

c*=2; //c=c*2

System.out.println(c);

c/=2; //c=c/2

System.out.println(c);

c%=2; //c=c%2

System.out.println(c);

int result;

result = a<b?b-a:a-b;

System.out.println(result);

}
}

You might also like