This is so hard....

Hi,

The following question is so hard for me. I don't know how to start. Could anyone give me some hints?

(c) Write a method called replaceString that takes three Strings as parameters and returns

a String as output. For the purpose of this explanation, we will call the first parameter

a, the second b, and the third c, but you are free to choose your own names for the

parameters (though you must respect the order of the parameters in this description). The

method looks for occurrences of b in a, and replaces each occurrence of b with c. It is

important to note that b and c need not be the same length. The final String after all of

the replacements should be returned.

For example, if the first parameter is 揝he sells seashells by the sea shore? the second

parameter is 搒h? and the third parameter is 搒hm? the method should return the String

揝he sells seashmells by the sea shmore?

[963 byte] By [Ace1a] at [2007-11-27 6:22:20]
# 1
I would start by looking over the String API for any methods that might be of use: http://java.sun.com/javase/6/docs/api/java/lang/String.html
Hippolytea at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...
# 2

Here's a hint:

[url=http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)]http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)[/url]

Edit:

Oh, good day, Hippolyte. Extra-caffeinated today, eh? :)

/me is glad we're not in a wild-west six-shooter duel.

kevjavaa at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...
# 3

My coffee is never far away. But by the timestamps, you had 5 minutes to beat me to a response!

And on a technical note, there is a simpler method than replaceAll, because the first argument to replaceAll is a regex string, which requires you to handle the case where you want to replace the literal substring "[ab]", for example.

Hippolytea at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...
# 4
> My coffee is never far away. But by the timestamps,> you had 5 minutes to beat me to a response!Ahh, yes... so it seems :). Good to see ya anyway... life treating you well up north?/me goes for a refill
kevjavaa at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...
# 5
> life treating you well up north?Same old same old. And you?The temperature got up to 34 癈 (93 癋) yesterday. Melted my igloo!
Hippolytea at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...
# 6

> Same old same old. And you?

Doing well here, surviving the pollen from the Kansas corn fields. My horse had a blowout, had to take the wife's to work.

> The temperature got up to 34 癈 (93 癋) yesterday.

> Melted my igloo!

Yikes... I'll bet the sled dogs are pissed.

kevjavaa at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...
# 7
Quite the opposite:[url #" style="display: block; background-image: url(' http://thecia.com.au/reviews/s/images/snow-dogs-7.jpg'); width: 350px; height: 220px] [/url]
Hippolytea at 2007-7-12 17:39:13 > top of Java-index,Java Essentials,Java Programming...