The operators defined for the built-in types
do sometimes behave in an unexpected way.
For example, whereas the
As logical operators Java includes, as C++, conjunction (&&) and disjunction (), as well as a number of bitwise logical operators. Also, we have an indexing operator which, unlike for C++, may be not defined for arbitrary types. Access to both static and dynamic methods involves the use of the dot operator.
The increment and decrement are defined only for the scalar types. Also, we have a conditional expression of the form b?: testing the condition b to deliver when it evaluates to true and otherwise.
Assignments in Java, like in C++, are written as var = expression with a single = symbol. As remarked previously, this convention is known to cause mistakes by programmers raised with languages such as Pascal or Modula-2.
In addition, Java offers, like C++, modifying assignments, which may be used as, for example, in n += 1, which is identical in meaning to n = n + 1.