logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    sfolax6776
    Jun 27, 2019
      ·  Edited: Feb 25, 2020

    4.2 How to compare different types of data? What is the order of precedence when arithmetic, relational and logical operators are mixed?

    in Introduction to Java

    A. Introduction

    When programming, we might need to compare different types of data such as char, int, double or String. We might also need to mix different types of expressions, relational operators and logical operators.


    B. Summary of comparison

    1. char types are compared by ASCII values.

    2. Strings are compared by ASCII values of each character, from left to right

    3. When compare two double/float values, we often compare the difference with a "small enough" value because of round off errors.

    4. A boolean variable x== true is the same as x

    C. Order of precedence:

    D. Try:

    Complete the following truth table


    0 comments
    0
    0 comments

    Questions? Email us at legionoflearners@gmail.com or join our WeChat group!

    • lol-101dotcom

    ©2020 Legion of Learners