Explain the logic you are trying to accomplish with this:
alphabet[i] = alphabet[i+1];
if (alphabet[i] == alphabet[25]) {
System.out.println("A");
}
The questions that I have here are:
1) Are you aware you are overriding the item in index i with the statement
alphabet[i] = alphabet[i+1]? So if i was 0 (A), i+1 would be 1 (B). Which means indexes 0 and 1 would both be
B after running that statement.
2) Why are you checking if the ith item is equal to the 25th item?
I feel like what you
should be doing is looping the length of the input (since you want the output to be the same length) instead of looping the alphabet array directly. The first thing I would do is create a method that loops through the alphabet array and returns an integer, representing the starting index (for the example in your first post, since we want to start at B, the method would return 1). I would call that method before the loop and store the returned value in an int that I would use in the loop. In the loop, I would loop until the length of the input, incrementing the index as well as the count. The last thing (or first thing, depends on your design) in the loop is to do a check to see if the current index is outside of the bounds of the alphabet array and, if it is, set the index to 0 (so it points at the letter A after Z).
I'm not sure if I explained that well. Does it make any sense?