code: private static int countElementOccurrence(Object element, Object[] array) {
  
          int count = 0;
          for ( int i= 0; i < array.length; ++i ) {
              Object arrayElement = array[i];
              if (arrayElement != null && element != null) {
                  if (arrayElement.equals(element)) {
                      count ++;
                  }
              }
          }    
          return count;
  
      }
docs: <p>Return the number of occurrances of a particular element in the
  array.</p>
  
  @param element object whose occurrance is to be counted in the array.
  @param array object representing the old value of this component.