Because that's what .toString does. Read the doc http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html
Returns a string representation of the contents of the specified array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(double). Returns "null" if a is null.
Because it does not match anything when you try to split it. The result therefore is a single bucket the string itself
Array.toString data handling in Java
-
13-04-2022 - |
Question
I'm confused the way data has been manipulated here in this case, thought will seek someones advice.
arrayDataOne = [ HEllO, NAME, ADDRESS, ZIPCODE ]
i.e
[0] = "HELLO"
[1] = "NAME"
[2] = "ADDRESS"
[3] = "ZIPCODE"
String arrayInString = ( Arrays.toString(arrayDataOne));
i.e
[ HEllO, NAME, ADDRESS, ZIPCODE ]
String[] arraySplit = arrayInString.split("\\|");
i.e
[0] = [[HEllO, NAME, ADDRESS, ZIPCODE ] ]
Question,
Why does string value displays as array though logically it's not stored as array in arrayInString ?
Why does arraySplit holds data with in [[ ****data**** ]] ? seems like array of array?
Edited: ( added more answer details )
To handle string without "[" "]" : read link
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow