I wrote a small program for hyperskill/jetbrains academy to encrypt the message "we found a treasure!" and print only the ciphertext (in lower case) by replacing each letter with the letter that is in the corresponding position from the end of the English alphabet (a→z, b→y, c→x, ... x→c, y →b, z→a) and without replace spaces or the exclamation mark.
I would like code review comments in terms of correct use of java.
package encryptdecrypt;
public class Main {
final static int lower_case_a = 'a';
final static int lower_case_z = 'z';
public static void main(String[] args) {
String s = "we found a treasure!";
StringBuffer reverse = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if ((int)c >= lower_case_a && (int)c <= lower_case_z)
reverse.append((char)(lower_case_z - c + lower_case_a));
else
reverse.append((char) c);
}
System.out.println(reverse.toString());
}
}