学习记录自己对java boolean 类型的理解

来源:互联网 发布:caffe bn层不收敛 编辑:程序博客网 时间:2024/05/20 23:36
public class demo {    public static  void  main(String args[]){        boolean b = true;        b = false;        System.out.println("b   is "+b);        b = true;        System.out.println("b is "+b);//        这几句代码会在控制台分别打印//        b is false//        b is true// <-------------------------------------分割线--------------->        // 布尔值本身就可以控制if语句        b  =true ;        if(b){            System.out.print("布尔变量 为true" );        }        b = false;        if(b){            System.out.print("布尔变量 为false" );        }        if(!b) {//System.out.print("这样判断 当Boolean  false的时候才会进来" );//这个判断相当于    if(b==false){}        }// 这上面的if判断如果判断了布尔值,那么 如果布尔值为 true 才会执行到if()判断里边的代码,如果 if()判断中的布尔值为false 那么 就不会执行到 if()判断里边的内容    }}
原创粉丝点击