I am trying to split a String array and use delimiters to remove any whitespace (including \t) but I am getting an empty element "" for some reason.
My Code:
String temp = " x = x + 9";
String[] tempArr = temp.split("\\s+");
The result I am getting:
tempArr[0] = ""
tempArr[1] = "x"
tempArr[2] = "="
...
I do not understand why I am getting an empty element in the first index of the array.
"\s+"is a typo, right? It should be:"\\s+"..trim()before.split(..)to get rid of leading and trailing white spaces."AxB".split("x")? And what in case of"xAxB".split("x")? Now simply changexwith space.