%java package testexample; import java.util.*; public class Testexample { public static void main(String[] args) { // Get Array String s = "AbCdEf"; String[] words = s.split("(?<=[a-z])(?=[A-Z])"); for(String word:words) { System.out.println(word); } // Output: Ab, Cd, Ef // Get String String ss = ""; for(String w : "AbCdEf".split("(?=[A-Z])")) { ss += w + " "; } System.out.println(ss.trim()); // Output: Ab Cd Ef // Get String - one line String sss = Arrays.asList("AbCd".split("(?=[A-Z])")).toString().replaceAll("\\[|,|\\]", "").trim(); System.out.println(sss); // Output: Ab Cd } }