I need to write a message and then change every letter by another following a certain number
Ex: if my message is abcd and the number chosen is 5 then my message has to become fghi.
I simply created a for loop going through the table char and created a table containing all the letter of the alphabet and a switch case for every letter. I thought this was like python, and i could loop to the beginning of my table, but it tells me that the index is out of bound. what are my possibilities?
char[] abc = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
for (int i = 0; 1 <= mesgIn.length; i++){
switch(mesgIn[i]) {
case 'a' -> mesgIn[i] = mesgIn[rot];
case 'b' -> mesgIn[i] = abc[1 + rot];
case 'c' -> mesgIn[i] = abc[2 + rot];
edit: int rot is the number of letter rotation i want to do. equals to wtv the user wants
edit 2: found an easier to do it. i simply added the alphabet twice in abc[], so abc[0] is 'a', but so is abc[26]