fork download
  1. class LetterByLetter {
  2.  
  3. public static void changeString(String str1, String str2) {
  4. System.out.println(str1);
  5. if (str1.length() == str2.length()) {
  6. char[] c1 = str1.toCharArray();
  7. char[] c2 = str2.toCharArray();
  8. for (int j = 0; j < str1.length(); j++) {
  9. if (c1[j] != c2[j]) {
  10. c1[j] = c2[j];
  11. System.out.println(c1);
  12. }
  13. }
  14. } else
  15. System.out.println("Strings are not of same length.");
  16. }
  17.  
  18. public static void main(String[] args) {
  19. changeString("floor", "brake");
  20. System.out.println();
  21. changeString("wood", "book");
  22. System.out.println();
  23. changeString("a fall to the floor", "braking the door in");
  24. }
  25. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
floor
bloor
broor
braor
brakr
brake

wood
bood
book

a fall to the floor
b fall to the floor
brfall to the floor
braall to the floor
brakll to the floor
brakil to the floor
brakin to the floor
brakingto the floor
braking o the floor
braking t the floor
braking ththe floor
braking thehe floor
braking the e floor
braking the d floor
braking the dofloor
braking the dooloor
braking the dooroor
braking the door or
braking the door ir
braking the door in