October 2011
Beginner
432 pages
10h 18m
English
There are several other ways you can examine a string variable and change its value. These advanced features are possible because strings are objects in the Java language. Working with strings develops skills you’ll use on other objects later.
One thing you are testing often in your programs is whether one string is equal to another. You do this by using equals() in a statement with both of the strings, as in this example:
String favorite = "piano";String guess = "ukulele";System.out.println("Is Ada's favorite instrument a " + guess + "?");System.out.println("Answer: " + favorite.equals(guess));
This example uses two different string variables. One, favorite, stores the name of Ada’s favorite instrument: ...
Read now
Unlock full access