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.

  • 相关阅读:
    关于本博客
    洛谷P3387 【模板】缩点 题解
    spfa学习笔记
    Google Chrome Download
    Kosaraju算法学习
    fhq treap 学习笔记
    OIerChat
    python request.get(h.html),用xpath获取数据为空
    k8s 用ingress暴露集群环境中的服务。
    harbor push 报received unexpected HTTP status: 500 Internal Server Error
  • 原文地址:https://www.cnblogs.com/allenblogs/p/2239228.html
Copyright © 2011-2022 走看看