SHARE
TWEET

Untitled

advictoriam Jan 17th, 2019 11 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ArrayOps
  2. {
  3.    /**
  4.       This method performs a linear search on the array identified by
  5.       the first parameter, while looking for the value indicated by
  6.       the second parameter.
  7.       @param values, an array of integers
  8.       @param valueToFind, an integer to look for in the array values
  9.       @ return, the index (subscript) of the array where the value
  10.             was found OR the length of the array if it was not found.
  11.    */
  12.    public static int findValue(int values[], int valueToFind)
  13.    {
  14.       for(int i = 0; i < values.length; i++)
  15.       {
  16.          if(values[i] == valueToFind){return i;}
  17.       }
  18.       return values.length;
  19.    }
  20. }
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