zoukankan      html  css  js  c++  java
  • Java初体验之bool

    Both the C++ and Java languages have boolean types, which are called bool and
    boolean, respectively. Although these types have similar names and uses, they are
    represented in completely different formats.

    Later implementations of C++ include a new bool type, whose values are
    represented by the new keywords true and false. In actuality, the bool type is
    represented as an int, and true and false correspond to 1 and 0 respectively.
    You can use int values and bool values interchangeably; 0 is converted to false,
    and all other number values are converted to true.

    The Java language defines the boolean type, whose values are represented by the
    true and false literals, which are the only valid values of the Java boolean type.
    Unlike the C++ bool type, the boolean type cannot be converted to or from the
    int type. In fact, the only valid conversion for a boolean value is to or from another
    boolean value.

    In Java programs, you cannot use int type values or expressions in place of
    boolean type values or expressions. For example, if you use an int in an if
    statement, which evaluates a boolean expression, the Java compiler will generate
    an error. This is a major change from C and C++, both of which use int values in
    logical expressions.

  • 相关阅读:
    Vue.config.productionTip = false;
    Node学习笔记
    Redux学习笔记------容器组件与展示组件分离
    Redux学习笔记------数据流
    Redux学习笔记------store
    Redux学习笔记------reducer
    Redux学习笔记------action
    Redux学习笔记------基础介绍
    过滤emoji表情
    textarea自适应高度
  • 原文地址:https://www.cnblogs.com/allenblogs/p/2239228.html
Copyright © 2011-2022 走看看