Usage of differences and || | & and &&,

& And && difference is & will perform on both sides, regardless of whether the establishment of the first
&& performed only one side, if the first condition is false, it will not take the second condition
, for example
public class Test2 {

    public static void main(String[] args){

        int i=3;

        if((i++>5)&(i++<9)){

            System.out.println(i);

            System.out.println ( "Congratulations, the implementation of conditional statements is over!");

        }

           System.out.println(i);

    }

}

The result is i = 5

public class Test2{

    public static void main(String[] args){

        int i=3;

        if((i++>5)&&(i++<9)){

            System.out.println(i);

            System.out.println ( "Congratulations, the implementation of conditional statements is over!");

        }    

        System.out.println(i);

    }

}

The result is i = 4

 || and | are mean "or" || difference is that as long as the first condition is met, the latter condition is no longer judge, but | to judge all conditions.


Note that when they carry out operations, & represents the first two numbers are turned into binary, and then the two numbers are only 1 to 1, the other for 0
| represents the number two as long as there is a 1 is 1, others are 0
---------------------
author: Beijing fleeting
source: CSDN
original: https: //blog.csdn.net/u010648159/article/details/52452447
copyright notice : This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/qianyuhebaobao/p/11205250.html