CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ

Control

Control Statements
Boolean expressions
Compare primitive data types

How to compare primitive data types

  • You can use the relational operators to create a Boolean expression that compares two operands and returns a boolean value that is either true or false.
  • If you compare two numeric operands that are not of the same type, Java will convert the less precise operand to the type of the more precise operand before doing the comparison.
  • By definition, a boolean variable evaluates to a boolean value of true or false.
Previous | Boolean expressions | Compare primitive data types | Compare strings | Next