public static String encode(String str) {
StringBuffer result = new StringBuffer();
int length = str.length;
for (int i=0; ichar ch = str.charAt(i);
if (ch >= 'A' && ch<= 'Z') {
ch = ((ch - 'A') +3 ) % 26 + 'A';
}
result.append(ch);
}
return result.toString();
}
用^运算符