• Java学习——Java运算符


    位运算符

    A = 0011 1100
    B = 0000 1101
    -----------------
    A&b = 0000 1100
    A | B = 0011 1101
    A ^ B = 0011 0001
    A << 2 = 1111 0000
    A >>> 2 = 0000 1111 ~A= 1100 0011

    例子

    package import_test;
    
    public class Employee {public static void main(String args[]){int a = 60;
            int b = 13;
            System.out.println(a | b);
            System.out.println(a & b);
            System.out.println(a ^ b);
            System.out.println(~a);
            System.out.println(a << 2);
            System.out.println(a >>> 2);
            
        }
    }

     结果

    61
    12
    49
    -61
    240
    15

    条件运算符

    public class Employee {
        public static void main(String args[]){
            int a = 10;
            int b = 8;
            String rev = a > b ? "a > b" : "a<= b";
            System.out.println(rev);
        }
    }

    结果

    a > b

    instanceOf运算符

    public class Employee {
        public static void main(String args[]){
            Employee eg = new Employee();
            String s = "String";
    
            System.out.println(s instanceof String);
            System.out.println(eg instanceof Employee);
            //boolean b = s instanceof Employee);
            //System.out.println(b);
        }
    }

    结果

    true
    true
  • 相关阅读:
    Magento交易邮件常见问题
    Magento谷歌分析设置
    magento SEO优化设置
    飞凤平台示范项目
    工厂生产线测量仪器的数据下发
    某外资汽车部件工厂车床联网系统
    行云仓库管理系统的概述
    arm v5,v6,v7?
    前端开发收藏夹
    mysql 事件
  • 原文地址:https://www.cnblogs.com/kaituorensheng/p/5750817.html
Copyright © 2020-2023  润新知