The comparison operator for numbers are the same as in Python. For built-in types, instead of == in Python, Java uses equals method.
Code Block |
---|
language | java |
---|
title | Strings in Java |
---|
| |
| Code Block |
---|
language | py |
---|
title | Strings in Python |
---|
| |
|
Python's Boolean operators: and, or, and not are replaced by: &&, || and ! in Java
Negation is also formed differently between those two programming languages
.
Code Block |
---|
language | java |
---|
title | Negation Strings in Java |
---|
| |
| Code Block |
---|
language | py |
---|
title | Negation Strings in Python |
---|
| x is not y |
|
Negation is also formed differently between those two programming languages
Code Block |
---|
language | java |
---|
title | Strings Negation in Java |
---|
| int myCounter = 0;
String myString = String.valueOf(myCounter);
if (myString.equals("0")) ... |
| Code Block |
---|
language | py |
---|
title | Strings Negation in Python |
---|
| myCounterx =is 0
myString = str(myCounter)
if myString == "0": ...not y |
|