zoukankan      html  css  js  c++  java
  • 运算符

    class Demo07
    {
    public static void main(String[] args)
    {
    //比较运算符
    System.out.println(3==4);//false

    //逻辑运算符
    //&:不管当&左边的值为啥,右边的表达式都走
    System.out.println(true&true);//true
    System.out.println(true&false);//false
    System.out.println(false&false);//false
    //&&: 当&&左边的值为false时,右边的表达式就不走了
    System.out.println(true&&true);//true
    System.out.println(true&&false);//false
    System.out.println(false&&false);//false
    /*int a=1;
    System.out.println(a==2&&a==a++);//false
    System.out.println(a);//1*/
    int a=1;
    System.out.println(a==2&&a==a++);//false
    System.out.println(a);//1
    // 两边只要有一边是true,总体结果就为true
    //|:不管当|左边的值为啥,右边的表达式都走
    System.out.println(true|true);//true
    System.out.println(true|false);//true
    System.out.println(false|false);//false
    //||:当||左边的值为true时,右边的表达式就不走了
    System.out.println(true||true);//true
    System.out.println(true||false);//true
    System.out.println(false||false);//false

    // ^:两边一样false,反之true
    System.out.println(true ^ true);//false
    System.out.println(true ^ false);//true
    System.out.println(false ^ false);//false

    //!:取反
    System.out.println(!false);//true

    //三元运算符

    (条件表达式)?表达式1:表达式2

    //比较两个数大小

    int a=1;

    int b=2;
    int max=a>b?a:b;
    System.out.println(max);//2

    /*

    boolean b = true;

    if(b==false)
    System.out.println("a");
    else if(b) //只有b代表b=true
    System.out.println("b");
    else if(!b)
    System.out.println("c");
    else
    System.out.println("d");

    */
    }
    }

  • 相关阅读:
    PIE SDK介绍
    PIE软件介绍
    PIE SDK与Python结合说明文档
    转载博客(Django2.0集成xadmin管理后台遇到的错误)
    python+django学习二
    python+django学习一
    HTML练习二--动态加载轮播图片
    HTML练习一
    LeetCode 999. 车的可用捕获量
    LeetCode 892. 三维形体的表面积
  • 原文地址:https://www.cnblogs.com/longmingyeyu/p/12532808.html
Copyright © 2011-2022 走看看