Here’s some code
private String replaceToEncrypt(String password) {
password.replace('A','@');
password.replace('E','=');
password.replace('I','!');
password.replace('J','?');
password.replace('O','*');
password.replace('P','#');
password.replace('R','&');
password.replace('S','$');
}
Using print statements its seems that nothing happens because ABCDEFGHIJKLMNOPQRSTUVWXYZ
before this method is ABCDEFGHIJKLMNOPQRSTUVWXYZ after
Thanks
You have to re-assign the result of each replacement, for example:
This is because all Strings in Java are immutable, and any operation that modifies a String what really does is return a new String with the modifications, the original String is kept unchanged.