Skip to content

Latest commit

 

History

History
33 lines (18 loc) · 944 Bytes

13.md

File metadata and controls

33 lines (18 loc) · 944 Bytes

Comparison Operators

>, Greater than, returns true if the value on the left is greater than the value on the right.

<, Less than, returns true if the value on the left is less than the value on the right.

>=, Greater than or equal to, returns true if the value on the left is greater than or equal to the value on the right.

<=, Less than or equal to, returns true if the value on the left is less than or equal to the value on the right.

==, returns true if two values are equal.

!=, returns true if two values are not equal.

Comparing Strings

Do not use == or != to compare strings.

Instead, you can compare one string to another by calling equals() from one of them.

String str1 = "hello";
String str2 = "hello";

str1.equals(str2);  // true
!str1.equals(str2); // false

You should know about how memory is being allocated. but 目前老师并没有讲

See you in workbook 3.1