赞
踩
package operator; public class Demo03 { public static void main(String[] args) { //关系运算符返回的结果: 正确,错误 布尔值 //和if一起使用 int a = 10; int b = 20; int c = 22; //取余,模运算 System.out.println(c%a); System.out.println(a>b); System.out.println(a<b); System.out.println(a==b); System.out.println(a!=b); } }
package operator; public class Demo04 { public static void main(String[] args) { //++ -- 自增,自减 一元运算符 int a = 3; int b = a++; //执行完这行代码后,先给b赋值,再自增 //a = a + 1; System.out.println(a); //a = a + 1; int c = ++a; //执行这行代码前,先自增,再给c赋值 System.out.println(a); System.out.println(b); System.out.println(c); //幂运算 2^3 2*2*2 = 8 很多运算,我们会使用一写工具类操作 double pow = Math.pow(2,3); System.out.println(pow); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。