Simple Caesar Cipher in Java
IMHO separating computation and printing is the most important improvement to do.


A code which can't do the computation separately is just a throw-away junk; you can't ever use it for anything else.
A code which can't do the printing separately is useless for the same reason. You can't use it for anything else, not even for the decryption.


In s simple snippet it doesn't matter much, but learning it later with complicated algorithms is much harder.



Note an asymmetry: Your SecretMessage stores the plaintext, but not the ciphertext. Ask yourself, if it needs to store anything.

Think about naming. Is the SecretMessage really a message? Or is it maybe an Encryptor? The way you implemented it, your naming isn't bad, but when you change it, you should reconsider it.

Does encrypt really encrypt its argument? Or would you expect it to do something else? Maybe being more verbose with encryptWithKey(char key) makes more sense.



Efficiency is usually overrated. You must think about using efficient algorithms and data structures for the job, but you can ignore nearly everything else. Anyway, before you start optimizing, make sure you optimize the real bottleneck, i.e., profile you code.

Anyway, using System.out.print for single characters may slow you down as it's synchronized and it flushes the output.

First building the result (using StringBuilder) would be faster. Moreover, it's a step in the right direction (Separation of concerns).