package com.gzxh.chapt02;
public class OPDemo {
/**
* @content
* 运算符
* 基本算数运算符:+ - * / % ++ --
* 赋值运算符:=(赋值) ==(恒等于)!=(不等于) += -= *= %= /=
* 逻辑运算符 :&& || !
* 条件运算符
*
*
* 丢失精度 !非
*/
public static void main(String[] args) {
// TODO 自动生成的方法存根
int x = 100; //创建变量并赋值
int y = 67;
int sum; //创建变量
sum = x + y;
System.out.println(sum);//167
int z = y - x;
System.out.println(z);//-33
int c = x * y;
System.out.println(c);//6700
int chu = x / y;
System.out.println(chu);//1
int qu = x % y;
System.out.println(qu);//33
System.out.println("==========================");
boolean flags;
flags = (x==y);
System.out.println(flags);//false
System.out.println(x!=y);//true
System.out.println("-----------------------");
// int a = 10,b = 20;
System.out.println("==================");
int s1 = x++;//先赋值、再自增
System.out.println(x);
System.out.println(s1);
int s2 = ++x;//先自增,再赋值
System.out.println(x);
System.out.println(s2);
int s3 = x--;
System.out.println(x);
System.out.println(s3);
int s4 = --x;
System.out.println(x);
System.out.println(s4);
}
}
java运算符
最新推荐文章于 2024-09-04 15:29:36 发布