SHARE
TWEET

Untitled

advictoriam Jan 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ArrayOps
  2. {
  3.    /**
  4.       This method goes through the array of integers identified by
  5.       the first parameter, while counting the number of occurrences
  6.       of the second parameter, a single integer, within the array.
  7.       @param theArray, an array of integers
  8.       @param theChar, an integer whose occurrences within the array
  9.          need to be counted
  10.       @ return, the count of the occurrences of the integer represented
  11.       by the second parameter in the array of integers.
  12.    */
  13.    public static int countOccurs(int[] theArray, int theInt)
  14.    {
  15.       int count = 0;
  16.  
  17.       for(int a : theArray)
  18.       {
  19.          if(a == theInt){count++;}
  20.       }
  21.       return count;
  22.    }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top