Java中&和&&的区别简单介绍
作者:yhntgbv 时间:2023-02-23 12:12:23
& 按位运算符,逻辑运算符
&& 逻辑运算符
相同点:只要有一端为假,则语句不成立
假设有三个参数
int x = 1;
int y = 2;
int q = 1;
作为逻辑运算符时,&左右两端条件式有一个为假就会不成立,但是两端都会运行
if((x+y)==4 & q++>0) {}
System.out.println(q); //q=2
&&也叫做短路运算符,因为只要左端条件式为假直接不成立,不会去判断右端条件式。
if((x+y)==4 && q++>0) {}
System.out.println(q); //q=1
来源:https://blog.csdn.net/m0_55096250/article/details/122318686
标签:Java&,&&
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java进程间通信之消息队列
2023-05-24 01:44:27
![](https://img.aspxhome.com/file/2023/3/97953_0s.png)
Android实现语音播放与录音功能
2022-01-21 15:39:09
Java用数组实现循环队列的示例
2022-06-26 15:09:48
Spring Data Jpa框架最佳实践示例
2021-11-25 00:43:01
Eclipse中改变默认的workspace的方法及说明详解
2022-07-31 12:07:21
C#实现汉字转换为拼音缩写的代码
2021-11-21 04:04:51
提升java开发效率工具lombok使用争议
2022-06-22 03:08:18
![](https://img.aspxhome.com/file/2023/9/104069_0s.jpg)
android调用国家气象局天气预报接口json数据格式解释
2022-09-16 21:08:24
Java try catch finally异常处理组合详解
2021-07-04 18:19:51
Java应用程序开发学习之static关键字应用
2021-12-20 13:23:41
![](https://img.aspxhome.com/file/2023/8/75708_0s.png)
mybatis教程之延迟加载详解
2023-02-19 12:45:18
![](https://img.aspxhome.com/file/2023/7/65607_0s.png)
Android使用animator实现fragment的3D翻转效果
2021-10-12 06:20:42
SpringMVC基于配置的异常处理器
2023-01-19 15:34:33
![](https://img.aspxhome.com/file/2023/4/115894_0s.png)
关于Java8 parallelStream并发安全的深入讲解
2023-11-15 06:37:35
![](https://img.aspxhome.com/file/2023/5/59545_0s.png)
解决springboot遇到autowire注入为null的问题
2022-04-15 02:37:59
![](https://img.aspxhome.com/file/2023/4/89624_0s.jpg)
Filter、Servlet、Listener的学习_动力节点Java学院整理
2021-08-12 00:05:49
![](https://img.aspxhome.com/file/2023/9/72529_0s.jpg)
Java 关键字 速查表介绍
2022-07-03 22:04:48
在Java代码中解析html,获取其中的值方法
2023-12-04 20:13:41
![](https://img.aspxhome.com/file/2023/7/125317_0s.jpg)
Java基于链表实现栈的方法详解
2022-07-02 11:39:20
![](https://img.aspxhome.com/file/2023/5/66045_0s.png)
C#影院售票系统毕业设计(4)
2023-03-27 17:45:29
![](https://img.aspxhome.com/file/2023/8/111088_0s.png)