I am trying to create a program that generates a string output from a string inputted by a user. The program must convert the string inputted by the user to string that is generated depending on the Key(any integer) which will be used as a basis of the to generate the secret code.
For example: if the user inputs "java" and the Key is "3" the output must be "mdyz". The problem is that i created an array of the 26 letters of the alphabet and if the Key is greater than 26 i always get an ArrayIndexOutOfBoundsException.
char [] alphabet = {'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'};
How can i loop through that array and return to the first index after it reaches the last index of the array?