reset password
Author Message
rabbott
Posts: 1649
Posted 22:36 Oct 05, 2013 |

An exercise asks you to write a method call that replaces the letter i with the letter x in Mississippi. It asks you to look up the replace method in the Java String class.

It turns out there are two replace methods. The first one lets you replace one character with another. That would seem to be the natural one to use. One problem is that you don't yet know how to write down a single character in Java. But if you looked it up and used that method the answer is marked incorrect. To get a correct score you have to use the second replace method, which lets you replace one string with another. In this case the string to be replaced and the replacement are both one character long.