Section 5: Operators and Assignments (Chapter 3)
Study NotesOperators require operands of certain types. The operands used with an operator influence which conversions can occur, and determine the type of the resulting expression. Some operators, such as + , can be applied to non-numeric values. Some operators are related , such as >> and >>> , and , & and && , but their behaviors are different. There are several forms of conversions, and all except for casts, occur implicitly depending on the context. The key to casting and conversion is to know the rules for widening numeric promotion, narrowing conversion, and converting references up and down the inheritance hierarchy (upcasting and downcasting ). The instanceof operator returns true if an object can be cast to the given reference type. In addition to the == operator, objects have the equals() method that can be used to compare objects. The == operator and the default equals() method consider every object to be unique. Classes can provide implementations of the equals() method that are less discriminatory. Correct implementation of the equals() must be understood . Some operators exhibit short-circuit behavior, which means that some operands may never be evaluated. Parameters are passed by value. Methods get their own copy of the argument values. This holds for values of primitive data types, as well as for reference values denoting objects. Objects themselves are not passed as arguments. |