Ledger Nano X - The secure hardware wallet
SHARE
TWEET

IndexGuess

a guest Apr 6th, 2020 170 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.  
  8.         int[] numberArray = {3, 5, 7, 12, 6};
  9.         int target = 12;
  10.  
  11.  
  12.         int indexNumber = GetIndex(numberArray, target);
  13.         System.out.println("Index found was: " + indexNumber);
  14.  
  15.     }
  16.  
  17.  
  18.  
  19.     public static int GetIndex(int[] nums, int target) {
  20.         for(int i=0; i<nums.length; i++) {
  21.             if(nums[i] == target) {
  22.                 return i;
  23.             } else {
  24.                 i++;
  25.             }
  26.         }
  27.  
  28.  
  29.         return 55;
  30.     }
  31.  
  32.  
  33. }
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