Java example to split a string String str = "A-B-C-D"; String[] strArray = str.split("-"); System.out.println(Arrays.toString(strArray)); // [A, B, C, D]