public class splitTest { public static void main(String[] args) { String a = "@123"; String b = "123@"; String c = "3@@@"; String[] aArr = a.split("@"); //[,123] String[] bArr = b.split("@"); //[123] String[] arr = c.split("@"); System.out.println(arr.length); String d = "1"; String[] dArr = a.split("1"); //[] String e = "12"; String[] eArr = a.split("1"); //[,2] } }