Operators in java are similar to c++ and c.
Operators are actions that manipulate, combine or compare variables.
Operators are actions that manipulate, combine or compare variables.
They fall into several categories as follows:
Operators | Symbols |
Assignment | += -= *= \= %= |
Arithmetic | + - * / % (modulus) ++ (increment) -- (decrement) |
String Concatenation | + |
Comparison or Relational Operators | == , != , > , >= , < <= |
Logical OR Boolean Comparison | ! & | ^ && || (&& are short circuit ops) |
Bitwise Comparison | ~ & | ^ (xor) << >> >>> |
Bitwise Assignment | &= |= ^= (xor) <<= >>= >>>= |
Conditional operator | ? (eg (expr1) ? expr2 : expr3 ) |
Object Creation | new (eg int a[] = new int[10];) |
Class of Object | instanceof |
Casting of Type | (var_type) |
Note: Changes in data type are done explicitly using a cast operation. For examplea = (int) b; assumes a is of type int and b is of another type.
Number of Operands for Operators
Java operators can be classified as unary, binary, or ternary—meaning taking one, two, or three arguments, respectively. A unary operator may appearbefore (prefix) its argument or after (postfix) its argument. A binary or ternary operator appears between its arguments.
No comments:
Post a Comment