具体代码如下:
public class liwei02{
public static void main(String[] args){
//1.自增、自减
//(1)单独使用:
int x;
x=10;
System.out.println(x);
x--;
System.out.println(x);
--x;
System.out.println(x);
x--;
System.out.println(x);
++x;
System.out.println(x);
//(2)与打印一起混合使用:
int y;
y=20;
System.out.println(y);
System.out.println(y--);
System.out.println(--y);
System.out.println(y++);
System.out.println(y--);
int z;
z=30;
int p;
p=z++;
System.out.println(z);
System.out.println(p);
p=++z;
System.out.println(z);
System.out.println(p);
//(3)混合使用
int a;
int b;
a=10;
b=20;
int q=a++ + --b;
System.out.println(a);
System.out.println(b);
System.out.println(q);
//2.赋值运算符
/*
+=
-=
*=
/=
%=
*/
int l;
l=10;
l+=2;
System.out.println(l);
l%=3;
System.out.println(l);
l*=4;
System.out.println(l);
l-=7;
System.out.println(l);
l/=5;
System.out.println(l);
//3.关系运算符
int w;
int e;
w=20;
e=30;
System.out.println(w<=e);
System.out.println(w>=e);
//4.逻辑运算符
/*
&&(与)
||(或)
!(非)
System.out.println(4<5 && 5>3);
System.out.println(true && false);
System.out.println(true && true);
System.out.println(false && false);
System.out.println(true || true);
System.out.println("true || false);
System.out.println(false || false);
System.out.println(!true);
System.out.println(!false);
int h;
h=10;
System.out.println(7<8 || --h>7);
System.out.println(h);
System.out.println(5<3 || --h>7);
System.out.println(h);
int k;
k=10;
System.out.println(7<8 && --k>7);
System.out.println(h);
System.out.println(5<3 && --k>7);
System.out.println(h);
//5.三元运算符
/*
?:
*/
int c;
int d;
c=10;
d=20;
int m;
m=c>d? c:d;
System.out.println(m);
m=c<d? c:d;
System.out.println(m);
}
}
结果图为: