The code runs properly the first time then run it again using the while loop and lets say the first time I entered AA and it becomes CC then it runs again I enter AA again it will come out with CCCC do it again it comes out with CCCCCC I don't want that I need it to not keep the data from the string each time it loops.
import java.util.*;
public class SecretCypher {
    public static void main(String args[]) {
        Scanner kb = new Scanner(System.in);
        StringBuffer e = new StringBuffer();
        System.out.println("Welcome to Secret Cypher!");
            char loop = 'Y';
            while(loop == 'Y' || loop == 'y') {
                System.out.println("");
                System.out.println("Enter your cypher in upper case.");
                String s = kb.nextLine();
                char[] cs = s.toCharArray();
                for (int i = 0; i < cs.length; i++) {
                    e.append((char)('A' + (cs[i] - 'A' + 2) % 26));
                }
                if(s == s.toLowerCase()) {
                    System.out.println("Remember to use upper case letters!");
                    System.exit(0);//Also I was bored of using break and this works any where in the code.
                }
                System.out.println(e.toString());
                System.out.println("Do you want to enter another cypher? > ");
                String again = kb.nextLine();
                if(again.charAt(0) == 'N') {
                    System.out.println("Hope you come back again!");
                    break;
                }
            }
    }
}
 
     
    