當前位置:
首頁 >
java之运算符
發布時間:2023/12/19
35
豆豆
package com.simope.myTest;import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;public class Test20151026 {public static void main(String[] args) {//乘除法運算最好使用移位運算,效率快
// 左移兩位 1000 -> 100000
// 右移三位 1000 -> 1System.out.println("8 << 2:" + (8 << 2)); System.out.println("8 >> 3:" + (8 >> 3)); System.out.println("17 >>> 3:" + (17 >>> 3)); System.out.println("***********************************");int a = 11, b = 17;
// 兩個操作數中位都為1,結果才為1,否則結果為0 11:1011、17:10001 -> 1:1System.out.println("a & b:" + (a & b)); // 兩個位只要有一個為1,那么結果就是1,否則就為0 11:1011、17:10001 -> 11011:27System.out.println("a | b:" + (a | b));// 如果位為0,結果是1,如果位為1,結果是0 11:1011 -> 0100System.out.println("~a:" + (~a));// 兩個操作數的位中,相同則結果為0,不同則結果為1 11:1011、17:10001 -> 11010:26System.out.println("a^b:" + (a ^ b));System.out.println("***********************************");//此遍歷是map遍歷效率最高的方法Map<String, Object> map = new HashMap<String, Object>();map.put("name", "張三");map.put("age", "21");map.put("sex", "man");map.put("scholl", "HBUT");Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();while (iter.hasNext()) {Map.Entry<String, Object> entry = iter.next();System.out.println("key:" + entry.getKey() + " value:" + entry.getValue());}System.out.println("***********************************");}}
?
轉載于:https://www.cnblogs.com/JimLy-BUG/p/5026674.html
總結
- 上一篇: seo行业赚钱的方式有哪些?
- 下一篇: stand up meeting 12/