Java教程

java运算符之与或非

本文主要是介绍java运算符之与或非,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
package operator;

public class Demo02 {
    public static void main(String[] args) {
        text0();

        text();

        text2();

        text3();
    }


    public  static  void  text3(){
         boolean a=true;
         boolean b=false;

        System.out.println("a && b:\t"+(a&&b));//false
        System.out.println("a || b:\t"+(a||b));//true
        System.out.println("!a && b:\t"+!(a&&b));//true

    }


    public  static  void  text2(){
        int a=3;
        int b=a++;
        int c=++a;

        System.out.println(a);//5
        System.out.println(b);//3
        System.out.println(c);//5


        double pow = Math.pow(2, 3);
        System.out.println(pow);//8.0
    }

    public  static  void  text0(){
        long a = 123132131313131L;
        int b=12345;
        short c=10;
        byte d=88;

        System.out.println(a+b+c+d);//long 123132131325574
        System.out.println(b+c+d);//int 12443
        System.out.println(c+d);//int  98
    }

    public  static   void text(){
        int a=10;
        int b=20;

        int c = 21;

        System.out.println(c%a);//21/10 ===2.....1 ===>>1
        System.out.println(c/a);//21/10 ===2.....1 ===>> 2

        System.out.println(a>b);//false
        System.out.println(a<b);//true
        System.out.println(a==b);//false
        System.out.println(a!=b);//true
    }
}

这篇关于java运算符之与或非的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!