Operator | Name | Method | Works with |
a + b | Plus | a.plus(b) | Number, String, Collection |
a - b | Minus | a.minus(b) | Number, String, Collection |
a * b | Star | a.multiply(b) | Number, String, Collection |
a / b | Divide | a.div(b) | Number |
a % b | Modulo | a.mod(b) | Integral number |
a++ ++a | Post increment Pre increment | a.next | Number,String,range |
a-- --a | Post decrement Pre decrement | a.previous | Number,String,range |
a **b | power | a.power(b) | Number |
a | b | Numerical or | a.or(b) | Integral number |
a & b | Numerical and | a.and(b) | Integral number |
a ^ b | Numerical xor | a.xor(b) | Integral number |
-a | Bitwise complement | a.negate() | Integral number,String |
a[b] | Subscript | a.getAt(b) | Object, list, map, String, Array |
a[b]=c | Subcript assignment | a.putAt(v,c) | Object, list, map, StringBuffer, Array |
a << b | Left shift | a.leftShift(b) | Integral number |
a >> b | Right shift | a.rightShift(b) | Integral number |
a >>> b | Right shift unsigned | a.rightShiftUnsigned(b) | Integral number |
switch(a){ case b: } | Classification | b.isCase(a) | Object, range, list, collection, pattern, closure |
a <=> b | Spaceship | a.compareTo(b) | java.lang.Comparable |
a > b | Greater than | a.compareTo(b) > 0 | |
a >= b | Greater than or equal to | a.compareTo(b) >= 0 | |
a < b | Less than | a.compareTo(b) < 0 | |
a <= b | Less than or equal to | a.compareTo(b) <= 0 | |