public class Main { public static void main(String args[]) throws Exception { String s3 = "A-BB-CCC"; String[] words = s3.split("-"); for (String str : words) { System.out.println(str); } } } /* A BB CCC */