previous |
start |
next .... [Slide 33] ....
Strings
- substring method yields substrings:
"Hello".substring(1, 3) is "el"
- Use equals to compare strings
if (greeting.equals("Hello"))
- == only tests whether the object references are
identical:
if ("Hello".substring(1, 3) == "el") ... // NO!
previous |
start |
next .... [Slide 33] ....