package abc;
import java.util.*;
public class TransformCharacters {
public static String changeCharacters(String string) {
for (int i = 0; i < string.length(); i++) {
char ch = string.charAt(i);
{
if (Character.isUpperCase(ch))
string.replace(ch, '1');
}
}
return string;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = "oYoroCoroSor";
System.out.println(changeCharacters(s));
}
}
Task was to replace all capital letters with 1.
The logic i used seems fine, but i am not getting the desired output.
the function returns the same string which has been sent to it, I have used Simple print statements at all steps in changeCharacters function, but i am not getting any output on the consloe except the same string whihc I have sent to it.