Say I have two string arrays:
String[] first = new String[]{"12","23","44","67"};
String[] second= new String[]{"12","22","46","67"};
I searched for a function like PHP's array_diff which will give me the difference of these two arrays like this:
{"23","44"}
Is there a in-built function for this operation, or should I create a for loop and check for the differences ?
List<String> first = new ArrayList<String>(Arrays.asList("12", "23");instead ofString[].Arrays.asListreturns aList, why would you pass this to aListconstructor? Second, depending on the use case an array is a perfectly acceptable data structure."12","22","23","67", what would he diff be?Arrays.asList, the returned list implements some of the methods (e.g.add()) of theListinterface by throwing an exception. I do not know the circumstances under which the OP wants to use the Strings and therefore choose the more flexible version.