data-manipulation

How do I remove objects from an array in Java?

落爺英雄遲暮 提交于 2019-11-25 22:01:18
问题 Given an array of n Objects, let\'s say it is an array of strings , and it has the following values: foo[0] = \"a\"; foo[1] = \"cc\"; foo[2] = \"a\"; foo[3] = \"dd\"; What do I have to do to delete/remove all the strings/objects equal to \"a\" in the array? 回答1: [If you want some ready-to-use code, please scroll to my "Edit3" (after the cut). The rest is here for posterity.] To flesh out Dustman's idea: List<String> list = new ArrayList<String>(Arrays.asList(array)); list.removeAll(Arrays

Split delimited strings in a column and insert as new rows [duplicate]

和自甴很熟 提交于 2019-11-25 21:54:31
问题 This question already has answers here : Split comma-separated strings in a column into separate rows (5 answers) Closed 3 years ago . I have a data frame as follow: +-----+-------+ | V1 | V2 | +-----+-------+ | 1 | a,b,c | | 2 | a,c | | 3 | b,d | | 4 | e,f | | . | . | +-----+-------+ Each of the alphabet is a character separated by comma. I would like to split V2 on each comma and insert the split strings as new rows. For instance, the desired output will be: +----+----+ | V1 | V2 | +----+--