摘要: 三元运算符 package operator; public class demo06 { public static void main(String[] args) { //三元运算符 x ? a : b //如果x=true,则结果为a,否则结果为b int x = 50; String re 阅读全文
posted @ 2023-02-03 16:51 chengh0618 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 扩展赋值运算符 package operator; public class demo05 { public static void main(String[] args) { int a = 10; int b =20; a +=b; // a = a + b a -=b; // a = a - 阅读全文
posted @ 2023-02-03 16:50 chengh0618 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 左移和右移详细说明 1、<<(左移) 1.运算规则: 按二进制形式把所有的数字向左移动对应的位数,高位移出(舍弃),低位的 空位补零。 2.语法格式: 需要移位的数字 << 移位的次数 例如: 3 << 2,则是将数字3左移2位 计算过程: 3 << 2 首先把3转换为二进制数字0000 0011, 阅读全文
posted @ 2023-02-03 15:45 chengh0618 阅读(838) 评论(0) 推荐(0) 编辑
摘要: 位运算符 package operator; public class demo04 { public static void main(String[] args) { /* 位运算符与,或,非 & | ~ A = 0011 1100 B = 0000 1101 A & B = 0000 1100 阅读全文
posted @ 2023-02-03 15:44 chengh0618 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 逻辑运算符 逻辑运算符 && , || , ! package operator; public class demo03 { public static void main(String[] args) { //逻辑运算符,与(and)、或(or)、非(取反) boolean a = true; 阅读全文
posted @ 2023-02-03 15:42 chengh0618 阅读(106) 评论(0) 推荐(0) 编辑