Home > Articles

Java Operators with Primitives and Objects

  • Print
  • + Share This
This chapter is from the book

Terms you'll need to understand:

  • Assignment
  • instanceof
  • equals

Techniques you'll need to master:

  • Constructing numeric literals in base ten, hexadecimal, and octal formats
  • Constructing character literals in Java's Unicode format
  • Constructing string literals in the quoted format
  • Understanding the effect of assignment and mathematical operators on primitives and objects
  • Understanding the operation of bitwise and logical operators in expressions
  • Understanding the implications of the various forms of the AND and OR logical operators
  • Understanding the correct use of the == comparison operator with primitives and objects
  • Predicting the operation of the equals method with combinations of various objects
  • Declaring, constructing, and initializing arrays of any type


Java uses literals and operators in a style that will be very familiar to all C programmers. In this chapter, we review the way Java uses literals to initialize primitive variables, create objects, and pass values to methods. We then review all of the Java operators used in expressions with both primitives and objects. You should not assume that the behavior of operators is the same in Java as in C. Pay particular attention to the difference between the == operator (double equals sign) and the equals method; this seems to confuse many programmers.

  • + Share This
  • 🔖 Save To Your Account