public static int findIndex (int[] my_array, int t) { if (my_array == null) return -1; int len = my_array.length; int i = 0; while (i < len) { if (my_array[i] == t) return i; else i=i+1; } return -1; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter