I've been trying for quite a while to be able to encrypt a string a certain way with the changing of the characters, I have managed to do that part by finding the rot13 :). However I'm quite confused on how to store the result as another String
so that it can be viewed later.
public static void main(String[] args) {
String s = "example string";
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c >= 'a' && c <= 'o') c += 6;
else if (c >= 'A' && c <= 'O') c += 6;
else if (c >= 'p' && c <= 'z') c -= 10;
else if (c >= 'P' && c <= 'Z') c -= 10;
System.out.print(c);
}
}
Is there possibly a way to store each individual value of char c
into separate strings and then join the strings together? I've tired using the StringBuilder
but have had no luck so far, Could anyone point me in the right direction? Thanks :)
EDIT
Yeah StringBuilder was indeed the way to go, thanks anyway :)