-3

This is my code: https://gyazo.com/8bf55245851665b91d482859b6413a75

I want to replace the first letter of the first word with the first letter of the second word but the replace tool won't work?

Mohanad
  • 71
  • 10
  • 2
    Welcome to Stack Overflow. An image of your code is not helpful. You should include the *relevant code* as a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). Please review [How do I ask a good question](https://stackoverflow.com/help/how-to-ask). – FluffyKitten Sep 09 '17 at 04:28
  • 2
    Why do you expect that a `Scanner` object has a `replace` method? Did you read the Javadoc for `Scanner`? – Jim Garrison Sep 09 '17 at 04:47
  • [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/q/285551/5221149) – Andreas Sep 09 '17 at 05:36

1 Answers1

1

In your code there is no String sc That you have used in the line for replacing the character. Use this line instead;

String replace1=fword1.replace(flfw,flsw);

I am referring to line 27 of your code.

And you don't require those for loops there.

Thank You.

Java Rookie
  • 432
  • 3
  • 12
  • 1
    Thank you works! But I dont understand why you say that I don't require those loops? – Mohanad Sep 10 '17 at 15:47
  • These loops are totally not required as you have no set of code repeat any number if times. Hope you get it. – Java Rookie Sep 11 '17 at 13:38
  • If an answer to any of your question is correct then better mark it as accepted(by clicking on the tick mark beside the answer) so that another user who has the same question can get the right answer from the pool of answers received – Java Rookie Sep 11 '17 at 13:40
  • Please note I am not asking you to to do the same with my answer I told this for your information only.Hope you understand. – Java Rookie Sep 11 '17 at 13:52