Common Names


Java Arrays Public New

Easy 

10min


Implement the findCommon method. When passed two arrays of names, it will return an array containing the names that appear in either or both arrays. The returned array should have no duplicates.

For example, calling CommonNames.findCommon(new String[]{'Ava', 'Emma', 'Olivia'}, new String[]{'Olivia', 'Sophia', 'Emma'}) should return an array containing Ava, Emma, Olivia, and Sophia in any order.

Java SE 8
   

  •   Example case: java.lang.UnsupportedOperationException at CommonNames.findCommon(CommonNames.java:4)
  •   Each array has distinct names: java.lang.UnsupportedOperationException at CommonNames.findCommon(CommonNames.java:4)
  •   Each array has duplicate names: java.lang.UnsupportedOperationException at CommonNames.findCommon(CommonNames.java:4)
  •   Arrays have some names in common: java.lang.UnsupportedOperationException at CommonNames.findCommon(CommonNames.java:4)