混淆视听的感脚(二)
生活随笔
收集整理的這篇文章主要介紹了
混淆视听的感脚(二)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?1.對下面代碼,打印出來的count是多少
@Testpublic void testsA2() {// int i = Integer.MAX_VALUE;// int j = i+1;// System.out.println(j);// System.out.println(Integer.MIN_VALUE);int count = 0;int begin = Integer.MAX_VALUE - 100;int end = Integer.MAX_VALUE;for (int i = begin; i <= end; i++) {count++;}System.out.println(count);}其實結果不是101,更不是100.why?打開注釋行代碼,會發Integer.MAX_VALUE+1 =?Integer.MIN_VALUE,導致該程序在for循環的時候跳不出來,所以卡死了,需要手動結束。
2.?
/*** int tmp = j;* j = j + 1;* j = tmp?;*/@Testpublic void testsA() {int j = 0;for (int i = 0; i < 100; i++)j = j++;System.out.println(j);}輸出的j為0
3.換個角度看
@Testpublic void testsA22() {double count = 1.0 / 0.0;System.out.println(count);//while (i != i + 0) {} String i = "what a fucky day";//while (i <= j && j <= i && i != j) {} Integer i = new Integer(0);//(i != 0 && i == -i) int i = Integer. MIN_VALUE; long i = Long. MIN_VALUE;}
?
轉載于:https://www.cnblogs.com/havenenjoy/p/4552803.html
總結
以上是生活随笔為你收集整理的混淆视听的感脚(二)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 明日方舟一共几个六星
- 下一篇: 多点怎么绑定银行卡(汉典多字的基本解释)