Nynaeve Ojeda wrote:I understand the following:
string.split() method = takes a line<string> and breaks it up into smaller strings according to the delimiter selected in this case "\\s+" which means all the next whitespace
That is correct.
propertyList.add(columns[0]) = should be adding the new smaller strings to the ArrayList propertyList beginning with the first index which is 0.
But that is not. The add method adds a single object to the list. columns[0] is the String at index 0 in the columns array. So it only adds that one String.
If the loop is included/implied in the string.split()method then it should automatically add all of the smaller strings on the original line until it hits the new line indicator
No, judging one one method's actions based on the actions of a completely different, unrelated method in a different class is not a good idea. Take a look at the API for List#add():
here. It says 'append the specified element to the end of the list.' Nothing about arrays, no plurals, and nothing to suggest that the action does anything more than to the single Object you pass to it. Since you pass it a single String that is at index 0 in the array, the List doesn't even know about the array, doesn't have access to it, and would find it quite impossible to add any other values from the array to the List. On the other hand, the String#split() method API:
here has multiple plural references, says it creates the array, and if you follow the trail to the multiple argument split() method explains that it does the search repeatedly.
So, given that the add() method just adds the single String to the list, and you are passing it columns[0], how can you get all the values of columns int the List?