java - 非短路算子
问题描述
我理解这部分:
Integer myInt;
myInt = new Integer(42);
if (myInt != null && myInt.intValue() == 42) {
System.out.println("Comparing 42 to 42");
}
myInt = null;
if (myInt != null & myInt.intValue() == 42) {
System.out.println("Comparing null to 42");
}
输出:
Comparing 42 to 42
Exception in thread "main" java.lang.NullPointerException
我不明白的是:
System.out.println("Result:" +(1 & 3));
System.out.println("Result2:" +(2 | 3));
Result:1
Result2:3
如果不比较布尔值,为什么要给出这个结果?
解决方案
推荐阅读
- angular - Ionic 4 显示来自 JSON 的特定键值
- r - R json多列
- android - 如何在android中单击按钮创建pdf文件?
- css - 有人知道三星galaxy s10的媒体查询吗
- ios - 视图控制器在 iOS 12 中响应应用程序委托通知,但在 iOS 13 中不响应
- java - 如何累积 for 循环内的 while 循环的总执行次数?
- android - 如果已设置,如何避免设置 firestore 文档字段
- typescript - 打字稿:具有键类型的对象受同一对象的其他键限制
- c - 如何在c中将多个字符串存储在数组中
- javascript - 关于:无法从“IDBRequest”读取“结果”属性