可能重复:
Java中的ROT-13函数?
我必须将所有字符从字符串中的13个位置转移
private static String encode(String line) {
char[] toEncode = line.toCharArray();
for (int i = 0; i < toEncode.length; i++) {
if (Character.isLetter(toEncode[i])) {
toEncode[i] += 13;
}
}
line = String.valueOf(toEncode);
return line;
}
Run Code Online (Sandbox Code Playgroud)
问题是,例如“ z”等于?。我该如何解决?
谢谢。