Here is a Python to Java dictionary.
Python | Java | Meaning |
Java Return Type |
Python Return Type |
Java Precedence |
---|---|---|---|---|---|
a[i] | a[i] | ith element of array a | Type of array element | Type of array element | 1 |
str(n) | n.toString( ) | dot operator | Return value of method | Return value of method | 1 |
a ** n | Math.pow(a, n) | a raised to the n power | double | float | 2 |
not expr | !expr | if expr is
true, return false; if false, return true |
boolean | bool | 3 |
+5 | +5 | positive 5 (not usually used) | int or double | int or float | 3 |
-5 | -5 | negative 5 | int or double | int or float | 3 |
x * y | x * y | x multiplied by y | int or double | int or float | 4 |
x / y | x / y | x divided by y | int or double | int or float | 4 |
x % y | x % y | x mod y (remainder from integer division) |
int or double | int or float | 4 |
x + y | x + y | sum of x and y | int or double | int or float | 5 |
s + t | s + t | concatenation of s and t | String | string | 5 |
x - y | x - y | difference of x minus y | int or double | int or float | 5 |
x < y | x < y | x is less than y | boolean | bool | 6 |
x > y | x > y | x is greater than y | boolean | bool | 6 |
x <= y | x <= y | x is less than or equal to y | boolean | bool | 6 |
x >= y | x >= y | x is greater than or equal to y | boolean | bool | 6 |
x == y | x == y | x is equal to y | boolean | bool | 7 |
x != y | x != y | x is not equal to y | boolean | bool | 7 |
expr1 and expr2 | expr1 && expr2 | logical and | boolean | bool | 8 |
expr1 or expr2 | expr1 || expr2 | logical or | boolean | bool | 9 |
y = x | y = x; | assign value of x to y y <-- x | Type of x | Type of x | 10 |
y += x | y += x; | y <-- y + x | Type of x | Type of x | 10 |
y += 1 | y++; | y <-- y + 1 | Type of x | Type of x | 10 |
y -= x | y -= x; | y <-- y - x | Type of x | Type of x | 10 |
y -= 1 | y--; | y <-- y - 1 | Type of x | Type of x | 10 |
y *= x | y *= x; | y <-- y * x | Type of x | Type of x | 10 |
y /= x | y /= x; | y <-- y / x | Type of x | Type of x | 10 |