In PHP there is the array_diff()
method that checks values of two arrays and returns the items for the difference between them. For example:
$arrExclusion = array('as', 'coisas', 'acontece', 'no', 'tempo', 'certo');
$arr = array('tudo', 'as', 'coisas' 'acontece', 'me', 'é', 'no', 'lícito',
'mas', 'seu', 'nem', 'tudo', 'tempo', 'me', 'convém', 'certo' );
$new_array = array_diff($arr, $arrExclusion);
The values of array $new_array
will be:
'everything', 'me', 'is', 'lawful', 'but', 'nor', 'everything', 'me'
Is there any method equivalent to array_diff()
in JAVA? If so, which one? If not, how could I do this?