Skip to content

Comparing values

Read · 1 of 3

Comparisons give a boolean

<, >, <=, >= work as in maths. == means is equal to (two equals signs; one = stores a value), and != means is not equal to.

For text, use a.equals(b), not ==. With Strings, == can say false even when the letters match.