A simple way can be to split the string on each character and join the parts using space as the delimiter.
Demo:
public class Main {
public static void main(String[] args) {
String s = "AB";
s = String.join(" ", s.split(""));
System.out.println(s);
}
}
Output:
A B
solved Add space between two characters in Java [duplicate]