import java.util.ArrayList;
import java.util.Arrays;
public class Solution {
public static String solution(String x) {
// convert String x to an array
String[] arrayX = x.split("");
// alphabet forwards, upper- and lowercase
String[] alphabet = "abcdefghijklmnopqrstuvwxyz".split("");
// alphabet backwards, upper- and lowercase
String[] tebahpla = "zyxwvutsrqponmlkjihgfedcba".split("");
ArrayList<String> decoded = new ArrayList<String>();
for(int i = 0; i < arrayX.length; i++) {
for(int j = 0; j < alphabet.length; j++) {
if(alphabet[j] == arrayX[i]) {
decoded.add(tebahpla[j]);
break;
} else if(arrayX[i] == alphabet[j].toUpperCase()) decoded.add(arrayX[i]);
}
}
// turn arrayX back into a string
String message = "";
for(int j = 0; j < decoded.size(); j++) {
message += decoded.get(j); System.out.println(decoded.get(j));
}
return message;
}
}
So, I'm working on a project in Java and I need to get messages printed out in which characters in the message [z..a] are replaced with their opposites [a..z], excluding uppercase and special characters (those will remain the same). Currently, when using System.out.println(Solution.solution(String x));
in my main method, I'm not receiving any output except for a line of whitespace. I've tried pretty much everything that I can think of, but no luck, as my code generates no errors.