Java Notes: Data types and Operators

Comprehend

  • A variable holds a value, while an object reference variable points to the memory that holds the object.
  • The short-circuit logical operators && and || operate only on boolean operands. For example, the expression
    9&&7 will not compile. Understand the difference between short-circuit logical operators and bitwise
    operators.
  • If the first expression of a && operator is false, the second expression is not evaluated, and if the first
    expression of a || operator is true, the second expression is not evaluated.

Look Out

  • Be on guard for words that are only slightly different from the Java keywords, such as synchronize instead of synchronized, implement instead of implements, and protect instead of protected.
  • Whether an array stores primitive variables or object references, the array itself is always an object.
  • It is illegal to include the array size in the array declaration.
  • Division by zero generates a runtime ArithmeticException only if the operands are integers. In case of float and double, the result of division by zero is infinity.
  • The result of the modulo operator always carries the sign of the first operand (i.e. the one before the operator);
    you can ignore the sign of the second operand.
  • You cannot instantiate an enum by using the new operator.

Memorize

  • Know the Java language keywords.
  • Know the range of values for all primitive data types.
  • All primitive data types except boolean and char are signed.
  • The first character of an identifier must be a letter, a dollar sign ($), or an underscore (_). Characters other than the first character in an identifier may be a letter, a dollar sign, an underscore, or a digit.


HIMMEL 2007-05-17 22:48 发表评论

你可能感兴趣的:(java)