I wanted to convert an array[] to an ArrayList. In java it is simpler to use
new ArrayList<Element>(Arrays.asList(array))
But what If I wanted to do some sanity check over elements in array before putting them in ArrayList. for e.g.
new ArrayList<Element>(Arrays.asList(array,Sanity.isNotNull))
i.e. Something similar to Comparator, add an element in ArrayList only when the function in second argument is true for that element.
I could always do a for and add elements myself, but is there anything inbuilt in Java? Second Question: is there a way to overload addAll function to achieve the above mentioned goal?