fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. { System.out.println(replaceCharacter("This is the letter i", 'i', "east"));
  12. }
  13.  
  14. public static String replaceCharacter(String w, char b, String v) {
  15. String result = "";
  16. for (int i = 0; i < w.length(); i++) {
  17. if (w.charAt(i) == b) {
  18. result += v;
  19. } else {
  20. result += w.charAt(i);
  21. }
  22. }
  23. return result;
  24. }
  25. }
Success #stdin #stdout 0.05s 27908KB
stdin
Standard input is empty
stdout
Theasts easts the letter east